bigquery

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package bigquery implements warehouse.Source for Google BigQuery (GoogleSQL) with cloud.google.com/go/bigquery.

Queries run as query jobs in the configured project and location with positional ("?") parameters, maximum_bytes_billed (max_bytes_billed) and a server-side job timeout matching the context deadline; a job whose caller goes away is canceled. Credentials come from credentials_file (service account, authorized user, impersonated service account or workload identity federation JSON) or Application Default Credentials.

Result values are converted to JSON-friendly Go values:

INT64              → int64
FLOAT64            → float64 ("NaN"/"Infinity"/"-Infinity" strings)
NUMERIC/BIGNUMERIC → float64 when lossless, else the exact decimal string
BOOL, STRING       → bool, string
BYTES              → base64 string
TIMESTAMP          → RFC 3339 string with nanoseconds, UTC
DATE               → "YYYY-MM-DD"
TIME               → "HH:MM:SS[.fffffffff]"
DATETIME           → "YYYY-MM-DDTHH:MM:SS[.fffffffff]"
JSON               → decoded value
GEOGRAPHY          → WKT string
INTERVAL           → canonical interval string ("Y-M D H:M:S")
RANGE<T>           → {"start": T|null, "end": T|null}
STRUCT             → object
ARRAY<T>           → array

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Logger receives warnings (default slog.Default()).
	Logger *slog.Logger
	// ClientOptions are appended to the options derived from the source
	// configuration (endpoint overrides, HTTP clients, credentials).
	ClientOptions []option.ClientOption
}

Options are optional settings.

type Source

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

Source is a warehouse.Source backed by a BigQuery client. It is safe for concurrent use.

func New

func New(ctx context.Context, name string, src config.WarehouseSource, opts Options) (*Source, error)

New creates a BigQuery client billed to src.ProjectID. ctx must stay valid for the lifetime of the source (credentials may be refreshed with it).

func (*Source) Close

func (s *Source) Close() error

Close closes the client.

func (*Source) Placeholder

func (s *Source) Placeholder(int) string

Placeholder returns "?" (BigQuery positional parameters).

func (*Source) Query

func (s *Source) Query(ctx context.Context, sql string, args []any, lim warehouse.Limits) (*warehouse.Result, error)

Query runs sql as a query job and returns the rows that fit within lim. No further pages are fetched once the size cap is reached.

Jump to

Keyboard shortcuts

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