bigquery

package
v0.8.9 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAuthError added in v0.8.4

func IsAuthError(err error) bool

IsAuthError reports whether err means the user has to log in again, e.g. Application Default Credentials are missing, expired, or need reauthentication. Denied access is not one, since logging in won't fix it.

func IsRuntimeFailure added in v0.8.0

func IsRuntimeFailure(err error) bool

IsRuntimeFailure reports whether err says nothing about the query itself, e.g. missing credentials, denied access, throttling, or an unreachable API.

Types

type BigqueryJob

type BigqueryJob interface {
	ID() string
	Location() string
	ProjectID() string
	Read(context.Context) (*bigquery.RowIterator, error)
	LastStatus() *bigquery.JobStatus
	Config() (bigquery.JobConfig, error)
	URL() string
	Cancel(context.Context) error
}

type Client

type Client interface {
	Close() error

	// GetDefaultProject returns the default project of the current user.
	GetDefaultProject() string

	// ListProjects lists all projects the current user has access to.
	ListProjects(ctx context.Context) ([]*cloudresourcemanager.Project, error)

	// ListDatasets lists all datasets in the specified project.
	ListDatasets(ctx context.Context, projectID string) ([]*bigquery.Dataset, error)

	// ListTables lists all tables in the specified dataset.
	ListTables(ctx context.Context, projectID, datasetID string) ([]*bigquery.Table, error)

	// GetDatasetMetadata returns the metadata of the specified dataset.
	GetDatasetMetadata(ctx context.Context, projectID, datasetID string) (*bigquery.DatasetMetadata, error)

	// GetTableMetadata returns the metadata of the specified table.
	GetTableMetadata(ctx context.Context, projectID, datasetID, tableID string) (*bigquery.TableMetadata, error)

	// GetRoutineMetadata returns the metadata of the specified routine, e.g. a procedure.
	GetRoutineMetadata(ctx context.Context, projectID, datasetID, routineID string) (*bigquery.RoutineMetadata, error)

	// DryRunSchema returns the result schema of the query from a dry run. It
	// covers what GetTableMetadata cannot fetch, e.g. INFORMATION_SCHEMA views.
	DryRunSchema(ctx context.Context, query string) (bigquery.Schema, error)

	// GetTableRecord returns the row of the specified table.
	GetTableRecord(ctx context.Context, projectID, datasetID, tableID string) (*bigquery.RowIterator, error)

	// Run runs the specified query.
	Run(ctx context.Context, q string, dryrun bool) (BigqueryJob, error)

	// JobFromID returns the job with the specified ID.
	JobFromProject(ctx context.Context, projectID, jobID, location string) (BigqueryJob, error)

	// Jobs returns the iterator of all jobs.
	Jobs(ctx context.Context) (*bigquery.JobIterator, error)

	// SearchTables searches for BigQuery tables matching the given query via Data Catalog.
	SearchTables(ctx context.Context, projectIDs []string, query string) ([]TableSearchResult, error)
}

func New

func New(ctx context.Context, projectID, location string, withCache bool, looger *logrus.Logger, onAuthError func(err error)) (Client, error)

New creates a Client. When onAuthError is not nil, missing or expired credentials don't fail it: onAuthError is called on an authentication error instead, and the client picks up a new login without a restart.

func NewAuthGuard added in v0.8.4

func NewAuthGuard(ctx context.Context, projectID string, newClient func(ctx context.Context) (Client, error), onAuthError func(err error), retryInterval time.Duration) (Client, error)

NewAuthGuard returns a Client that reports authentication errors to onAuthError, once until a call succeeds, and recreates the client with newClient at most once per retryInterval until it authenticates again. Missing credentials don't fail it, so that the user can log in later.

type TableSearchResult added in v0.6.0

type TableSearchResult struct {
	ProjectID   string
	DatasetID   string
	TableID     string
	Description string
}

TableSearchResult holds the project/dataset/table identifiers for a search hit.

Directories

Path Synopsis
Package mock_bigquery is a generated GoMock package.
Package mock_bigquery is a generated GoMock package.

Jump to

Keyboard shortcuts

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