bqx

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidProjectName = errors.New("Invalid project name")
	ErrInvalidDatasetName = errors.New("Invalid dataset name")
	ErrInvalidTableName   = errors.New("Invalid table name")
	ErrInvalidFQTable     = errors.New("Invalid fully qualified table name")
)

These errors are self-explanatory.

Functions

func Customize

func Customize(schema bigquery.Schema, subs map[string]bigquery.FieldSchema) bigquery.Schema

Customize recursively traverses a schema, substituting any fields that have a matching name in the provided map.

func PrettyPrint

func PrettyPrint(schema bigquery.Schema, simplify bool) (string, error)

PrettyPrint generates a formatted json representation of a Schema. It simplifies the schema by removing zero valued fields, and compacting each field record onto a single line. Intended for diagnostics and debugging. Not suitable for production use.

func RemoveRequired

func RemoveRequired(schema bigquery.Schema) bigquery.Schema

RemoveRequired recursively traverses a schema, setting Required to false in all fields that are not fundamentally required by BigQuery.

Types

type PDT

type PDT struct {
	Project string
	Dataset string
	Table   string
}

PDT contains a bigquery project, dataset, and table name.

func ParsePDT

func ParsePDT(fq string) (PDT, error)

ParsePDT parses and validates a fully qualified bigquery table name of the form project.dataset.table. None of the elements needs to exist, but all must conform to the corresponding naming restrictions.

func (PDT) CreateTable

func (pdt PDT) CreateTable(ctx context.Context, client *bigquery.Client, schema bigquery.Schema, description string,
	partitioning *bigquery.TimePartitioning, clustering *bigquery.Clustering) error

CreateTable will create a new table, or fail if the table already exists. It will also set appropriate time-partitioning field and clustering fields if non-nil arguments are provided. Returns error if the dataset does not already exist, or if other errors are encountered.

func (PDT) UpdateTable

func (pdt PDT) UpdateTable(ctx context.Context, client *bigquery.Client, schema bigquery.Schema) error

UpdateTable will update an existing table. Returns error if the table doesn't already exist, or if the schema changes are incompatible.

Jump to

Keyboard shortcuts

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