Documentation ¶
Overview ¶
Package x_dataset extends bqiface.Dataset with useful abstractions for simplifying interactions with bigquery. This package is intended to replace bqext. It is currently untested and buggy!!
Index ¶
- Variables
- type Dataset
- func (dsExt *Dataset) DestQuery(query string, dest bqiface.Table, disposition bigquery.TableWriteDisposition) bqiface.Query
- func (dsExt Dataset) GetPartitionInfo(ctx context.Context, table string, partition string) (PartitionInfo, error)
- func (dsExt *Dataset) QueryAndParse(ctx context.Context, q string, structPtr interface{}) error
- func (dsExt *Dataset) ResultQuery(query string, dryRun bool) (bqiface.Query, error)
- type PartitionInfo
Constants ¶
This section is empty.
Variables ¶
var ( ErrNilBqClient = errors.New("nil BqClient") ErrNilQuery = errors.New("BqClient.Query failed") )
Errors returned by Dataset functions.
Functions ¶
This section is empty.
Types ¶
type Dataset ¶
Dataset provides extensions to the bigquery Dataset and Dataset objects to streamline common actions. It encapsulates the Client and Dataset to simplify methods.
func NewDataset ¶
func NewDataset(ctx context.Context, project, dataset string, clientOpts ...option.ClientOption) (Dataset, error)
NewDataset creates a Dataset for a project. httpClient is used to inject mocks for the bigquery client. if httpClient is nil, a suitable default client is used. Additional bigquery ClientOptions may be optionally passed as final
clientOpts argument. This is useful for testing credentials.
NOTE: Caller should close the BqClient when finished.
func (*Dataset) DestQuery ¶
func (dsExt *Dataset) DestQuery(query string, dest bqiface.Table, disposition bigquery.TableWriteDisposition) bqiface.Query
DestQuery constructs a query with common Config settings for writing results to a table. If dest is nil, then this will create a DryRun query. TODO - should disposition be an opts... field instead?
func (Dataset) GetPartitionInfo ¶
func (dsExt Dataset) GetPartitionInfo(ctx context.Context, table string, partition string) (PartitionInfo, error)
GetPartitionInfo provides basic information about a partition.
func (*Dataset) QueryAndParse ¶
QueryAndParse executes a query that should return a single row, with all struct fields that match query columns filled in. The caller must pass in the *address* of an appropriate struct. TODO - extend this to also handle multirow results, by passing slice of structs.