bqutil

package
v0.0.3 Latest Latest
Warning

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

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

README

The bqutil package

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseModel

func ParseModel(row map[string]bigquery.Value, model interface{}) (interface{}, error)

ParseModel will parse a bigquery row map into a new item matching model. Type of model must be struct annotated with qfield tags.

Types

type TableUtil

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

TableUtil provides utility functions on tables in a dataset. It encapsulates the Client and Dataset to simplify methods. TODO(gfr) Should this be called DatasetUtil ?

func NewTableUtil

func NewTableUtil(project, dataset string, httpClient *http.Client, clientOpts ...option.ClientOption) (TableUtil, error)

NewTableUtil creates a TableUtil 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 (*TableUtil) GetTableStats

func (util *TableUtil) GetTableStats(table string) bigquery.TableMetadata

GetTableStats fetches the Metadata for a table. TODO(gfr) Is this worth having, or is it too small and non-idiomatic?

func (*TableUtil) QueryAndParse

func (util *TableUtil) QueryAndParse(q string, model interface{}) (interface{}, error)

QueryAndParse executes a query that should return a single row, with column labels matching the qfields tags in the provided model struct.

func (*TableUtil) ResultQuery

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

ResultQuery constructs a query with common Config 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