bigquery

package
v0.0.7 Latest Latest
Warning

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

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

README


title: 'BigQuery'

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

Configuration

The connector requires the following configuration parameters:

  • type (string): Constant - bigquery
  • project_id (string): Your Google Cloud Project ID
  • dataset (string): The BigQuery dataset name
  • credentials (string): Google Cloud service account credentials JSON as a string

Example Configuration

type: bigquery
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 Credentials JSON for BigQuery

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"`
}

func (Config) Doc

func (c Config) Doc() string

func (Config) Type

func (c Config) Type() string

type Connector

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

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