Documentation ¶
Overview ¶
Package bq provides a wrapper for Google's BigQuery library as well as general setup of the BigQuery client and streaming inserts usign bqstreamer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeLegacy ¶
Encode takes a struct and returns a BigQuery compatible encoded map for the legacy BigQuery library.
func EnsureTable ¶
Ensure that the given table is up-to-date. - If the table does not exist, it will be created - If the table exists but the schema is outdated, it will be updated - Otherwise nothing happens The function panics if any of its API calls fail.
func IsSameSchema ¶
Determines whether two BigQuery schemas are the same. Currently does not support nested schemas and only checks the name and type of the fields.
func SetupStreamingInserts ¶
func SetupStreamingInserts()
Sets up workers for handling streaming inserts using multiple concurrent go routines. Expects the same environment variables as Setup().
Types ¶
type BigQueryWrapper ¶
type BigQueryWrapper struct { Client *bigquery.Client ProjectId string DatasetId string TablePrefix string }
func NewBigQueryWrapper ¶
func NewBigQueryWrapper(client *bigquery.Client, projectId, datasetId string) *BigQueryWrapper
Creates a new wrapper for a bigquery client
func Setup ¶
func Setup() *BigQueryWrapper
Sets up the BigQuery client wrapper. Assumes that the following environment variables are set: BIGQUERY_PROJECT_ID: The ID of the bigquery project, from the Google Cloud console BIGQUERY_DATASET_ID: The ID of dataset to use. BIGQUERY_SERVICE_ACCOUNT: A filepath for a bigquery service account configuration OR a base64 encoded string with the service account credentials. The created wrapper is returned.
func (*BigQueryWrapper) AddRow ¶
func (w *BigQueryWrapper) AddRow(tableId string, row interface{}) error
func (*BigQueryWrapper) Dataset ¶
func (w *BigQueryWrapper) Dataset() *bigquery.Dataset
func (*BigQueryWrapper) TableId ¶
func (w *BigQueryWrapper) TableId(tableId string) string
func (*BigQueryWrapper) UseTablePrefix ¶
func (w *BigQueryWrapper) UseTablePrefix(useIt bool)