bq

package
v0.0.0-...-c783a93 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package bq provides definitions and methods for structs used for querying data from the a dataset on BigQuery

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fetch

Fetch executes a BigQuery Job using the supplied context, SelectBuilder and returns a row iterator with results.

func In

func In(field string, values ...string) string

In can be used to write conditions of form "field IN (list of values)"

func JExtract

func JExtract(json string, path string) string

JExtract formats a Column in a select query to use JSON_EXTRACT_SCALAR As per https://cloud.google.com/bigquery/docs/reference/legacy-sql#json_extract_scalar

Example: JExtract('payload','action') ==> JSON_EXTRACT_SCALAR(payload,'$.action')

func Like

func Like(field string, values ...string) string

Like can be used to write conditions form "field LIKE (list of values)"

func NotIn

func NotIn(field string, values ...string) string

NotIn can be used to write conditions of form "field NOT IN (list of values)"

func NotLike

func NotLike(field string, values ...string) string

NotLike can be used to write conditions of form "field NOT LIKE (list of values)"

Types

type Columns

type Columns []Pair

Columns Stores an array of Column Name,Label Pairs.

type Pair

type Pair struct {
	Key   string
	Value string
}

Pair stores key value pairs that are used in various methods of the builder

The syntax results in a statement like "Select html_url as url" in traditional SQL

type SelectBuilder

type SelectBuilder builder.Builder

SelectBuilder is an exported Builder that allows users to build Legacy SQL queries on BigQuery

func Debug

func Select

func Select(c Columns, args ...string) SelectBuilder

Select acts as wrapper to easily start a new SelectBuilder Chain

func SelectAll

func SelectAll() SelectBuilder

SelectAll functions similar to the Select Wrapper

func (SelectBuilder) And

func (b SelectBuilder) And(conditions ...string) SelectBuilder

And adds all strings in conditions to b.Conditions with an "AND" prefix

func (SelectBuilder) From

func (b SelectBuilder) From(names ...string) SelectBuilder

From adds all strings in names to use as tables in the query

func (SelectBuilder) IsEmpty

func (b SelectBuilder) IsEmpty() bool

IsEmpty checks if the builder has any fields and returns true or false

func (SelectBuilder) Limit

func (b SelectBuilder) Limit(limit uint64) SelectBuilder

Limit adds a limit clause to the query

func (SelectBuilder) Or

func (b SelectBuilder) Or(conditions ...string) SelectBuilder

Or adds all strings in conditions to b.Conditions with an "OR" prefix

func (SelectBuilder) OrderBy

func (b SelectBuilder) OrderBy(fields ...string) SelectBuilder

OrderBy adds all strings in fields to b.SortFields separated by spaces

func (SelectBuilder) SQL

func (b SelectBuilder) SQL() (string, error)

SQL composes the query string to use with BigQuery's Legacy SQL standard

func (SelectBuilder) Select

func (b SelectBuilder) Select(cols Columns, args ...string) SelectBuilder

Select adds field and label from Columns{Pair{Key: field, Value: label)} to the list columns to select

For Example: Select({'html_url': 'url'}) results in SELECT html_url url

Select also supports JSON Extracted field names - by passing the path as Column key and JSON field name as second argument

func (SelectBuilder) SelectAll

func (b SelectBuilder) SelectAll() SelectBuilder

SelectAll sets Fields in the selectComponents to "*", which results in a "SELECT * FROM..." like query

func (SelectBuilder) Where

func (b SelectBuilder) Where(condition string) SelectBuilder

Where adds condition to the b.Condition. If previous conditions exist, it behaves like b.And(condition)

Jump to

Keyboard shortcuts

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