bigquery

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

README


title: 'BigQuery'

This connector allows you to connect to Google BigQuery and execute queries against your datasets.

Config Schema

Field Type Required Description
type string yes constant: bigquery
project_id string yes Your Google Cloud Project ID
dataset string yes The BigQuery dataset name
credentials string yes Google Cloud service account credentials JSON
endpoint string no Custom BigQuery API endpoint (for testing)
conn_string string no JSON-formatted connection string with all parameters

Config example:

type: bigquery
project_id: your-project-id
dataset: your_dataset
credentials: |
  {
    "type": "service_account",
    ...
  }

Or as alternative with JSON-formatted connection string:

type: bigquery
conn_string: |
  {
    "project_id": "your-project-id",
    "dataset": "your_dataset",
    "credentials": {
      "type": "service_account",
      ...
    }
  }

Features

  • Table discovery
  • Query execution with parameters
  • Schema inference
  • Row sampling

Service Account Setup

To use this connector, you'll need to set up a Google Cloud service account with appropriate permissions:

1. Go to Google Cloud Console
2. Create a Service Account
  • Navigate to IAM & AdminService Accounts (direct link).
  • Click Create Service Account.
  • Enter the account name and description, then click Create.
  • In the Grant this service account access to the project section, add the following roles:
    • BigQuery Data Viewer (view data)
    • BigQuery Metadata Viewer (to be able get meta information about tables)
    • BigQuery Job User (to be able execute queries)
  • Click Done.

img

3. Create a JSON Key
  • Find the newly created service account in the list.
  • Open its page and go to the Keys tab.
  • Click Add KeyCreate new key.
  • Select JSON and click Create.
  • The credentials file will be automatically downloaded (your-project-key.json).

Limitations

  • BigQuery doesn't support traditional primary keys
  • Credentials must be provided as a JSON string
  • Some BigQuery-specific features like clustering and partitioning are not exposed through this connector

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ProjectID   string `json:"project_id" yaml:"project_id"`
	Dataset     string `json:"dataset" yaml:"dataset"`
	Credentials string `json:"credentials" yaml:"credentials"`
	Endpoint    string `yaml:"endpoint"`
	ConnString  string `yaml:"conn_string"`
	IsReadonly  bool   `yaml:"is_readonly"`
}

func (Config) Doc

func (c Config) Doc() string

func (Config) ExtraPrompt added in v0.0.8

func (c Config) ExtraPrompt() []string

func (Config) Readonly added in v0.2.1

func (c Config) Readonly() bool

func (Config) Type

func (c Config) Type() string

func (*Config) UnmarshalYAML added in v0.1.0

func (c *Config) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements the yaml.Unmarshaler interface to allow for both direct connection string or full configuration objects in YAML

type Connector

type Connector struct {
	// contains filtered or unexported fields
}

func (*Connector) Close added in v0.0.8

func (c *Connector) Close() error

Close releases any resources held by the connector

func (*Connector) Config added in v0.0.8

func (c *Connector) Config() connectors.Config

func (*Connector) Discovery

func (c *Connector) Discovery(ctx context.Context) ([]model.Table, error)

func (*Connector) GuessColumnType

func (c *Connector) GuessColumnType(sqlType string) model.ColumnType

func (*Connector) InferQuery

func (c *Connector) InferQuery(ctx context.Context, query string) ([]model.ColumnSchema, error)

func (*Connector) InferResultColumns

func (c *Connector) InferResultColumns(ctx context.Context, query string) ([]model.ColumnSchema, error)

func (*Connector) Ping

func (c *Connector) Ping(ctx context.Context) error

func (*Connector) Query

func (c *Connector) Query(ctx context.Context, endpoint model.Endpoint, params map[string]any) ([]map[string]any, error)

func (*Connector) Sample

func (c *Connector) Sample(ctx context.Context, table model.Table) ([]map[string]any, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL