bqutil

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

README

The bqutil package

This package contains utilities that facilitate various bigquery operations, notably query processing.

Documentation

Overview

Package bqutil includes generally useful abstractions for simplifying interactions with bigquery. Production utilities should go here, but test facilities should go in a separate bqtest package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TableExt added in v0.0.4

type TableExt struct {
	BqClient *bigquery.Client
	Dataset  *bigquery.Dataset
}

TableExt provides extensions to the bigquery Dataset and Table objects to streamline common actions. It encapsulates the Client and Dataset to simplify methods. TODO(gfr) Should this be called DatasetUtil ? TODO(gfr) Rename this to TableExt (extensions)

func NewTableExt added in v0.0.4

func NewTableExt(project, dataset string, clientOpts ...option.ClientOption) (TableExt, error)

NewTableExt creates a TableExt 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.

func (*TableExt) QueryAndParse added in v0.0.4

func (util *TableExt) QueryAndParse(q string, structPtr interface{}) error

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.

func (*TableExt) ResultQuery added in v0.0.4

func (util *TableExt) ResultQuery(query string, dryRun bool) *bigquery.Query

ResultQuery constructs a query with common QueryConfig settings for writing results to a table. Generally, may need to change WriteDisposition.

Jump to

Keyboard shortcuts

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