The target-bigquery Meltano loader sends data into BigQuery after it was pulled from a source using an extractor.

Alternative variants #

Multiple variants of target-bigquery are available. This document describes the transferwise variant.

Alternative variants are:

Getting Started #

Prerequisites #

If you haven't already, follow the initial steps of the Getting Started guide:

  1. Install Meltano
  2. Create your Meltano project
  3. Add an extractor to pull data from a source

Installation and configuration #

  1. Add the target-bigquery loader to your project using meltano add :

    meltano add loader target-bigquery --variant transferwise
  2. Configure the settings below using meltano config .

Next steps #

Follow the remaining steps of the Getting Started guide:

  1. Run a data integration (EL) pipeline
If you run into any issues, learn how to get help.

Capabilities #

These capabilities can also be overriden by specifying the capabilities key in your meltano.yml file.

Settings #

target-bigquery requires the configuration of the following settings:

The settings for loader target-bigquery that are known to Meltano are documented below. To quickly find the setting you're looking for, use the Table of Contents at the top of the page.

You can override these settings or specify additional ones in your meltano.yml by adding the settings key. Please consider adding any settings you have defined locally to this definition on MeltanoHub by making a pull request to the YAML file that defines the settings for this loader.

Credentials Path (credentials_path) #

  • Environment variable: GOOGLE_APPLICATION_CREDENTIALS, alias: TARGET_BIGQUERY_CREDENTIALS_PATH
  • Default: $MELTANO_PROJECT_ROOT/client_secrets.json

Fully qualified path to client_secrets.json for your service account.

See the “Activate the Google BigQuery API” section of the repository’s README and https://cloud.google.com/docs/authentication/production.

By default, this file is expected to be at the root of your project directory.

How to use #

Manage this setting using meltano config or an environment variable:

meltano config target-bigquery set credentials_path <credentials_path>

export GOOGLE_APPLICATION_CREDENTIALS=<credentials_path>

Dataset Id (dataset_id) #

BigQuery dataset

How to use #

Manage this setting using meltano config or an environment variable:

meltano config target-bigquery set dataset_id <dataset_id>

export TARGET_BIGQUERY_DATASET_ID=<dataset_id>

Project Id (project_id) #

BigQuery project

How to use #

Manage this setting using meltano config or an environment variable:

meltano config target-bigquery set project_id <project_id>

export TARGET_BIGQUERY_PROJECT_ID=<project_id>

Location (location) #

Region where BigQuery stores your dataset

How to use #

Manage this setting using meltano config or an environment variable:

meltano config target-bigquery set location <location>

export TARGET_BIGQUERY_LOCATION=<location>

Batch Size Rows (batch_size_rows) #

Maximum number of rows in each batch. At the end of each batch, the rows in the batch are loaded into BigQuery.

How to use #

Manage this setting using meltano config or an environment variable:

meltano config target-bigquery set batch_size_rows 100000

export TARGET_BIGQUERY_BATCH_SIZE_ROWS=100000

Flush All Streams (flush_all_streams) #

Flush and load every stream into BigQuery when one batch is full. Warning - This may trigger transfer of data with low number of records, and may cause performance problems.

How to use #

Manage this setting using meltano config or an environment variable:

meltano config target-bigquery set flush_all_streams true

export TARGET_BIGQUERY_FLUSH_ALL_STREAMS=true

Parallelism (parallelism) #

The number of threads used to flush tables. 0 will create a thread for each stream, up to parallelism_max. -1 will create a thread for each CPU core. Any other positive number will create that number of threads, up to parallelism_max.

How to use #

Manage this setting using meltano config or an environment variable:

meltano config target-bigquery set parallelism 0

export TARGET_BIGQUERY_PARALLELISM=0

Max Parallelism (max_parallelism) #

Max number of parallel threads to use when flushing tables.

How to use #

Manage this setting using meltano config or an environment variable:

meltano config target-bigquery set max_parallelism 16

export TARGET_BIGQUERY_MAX_PARALLELISM=16

Default Target Schema (default_target_schema) #

Name of the schema where the tables will be created. If schema_mapping is not defined then every stream sent by the tap is loaded into this schema.

How to use #

Manage this setting using meltano config or an environment variable:

meltano config target-bigquery set default_target_schema <default_target_schema>

export TARGET_BIGQUERY_DEFAULT_TARGET_SCHEMA=<default_target_schema>

Default Target Schema Select Permission (default_target_schema_select_permission) #

Grant USAGE privilege on newly created schemas and grant SELECT privilege on newly created

How to use #

Manage this setting using meltano config or an environment variable:

meltano config target-bigquery set default_target_schema_select_permission <default_target_schema_select_permission>

export TARGET_BIGQUERY_DEFAULT_TARGET_SCHEMA_SELECT_PERMISSION=<default_target_schema_select_permission>

Schema Mapping (schema_mapping) #

(Experimental) Useful if you want to load multiple streams from one tap to multiple BigQuery schemas. If the tap sends the stream_id in - format then this option overwrites the default_target_schema value. Note, that using schema_mapping you can overwrite the default_target_schema_select_permission value to grant SELECT permissions to different groups per schemas or optionally you can create indices automatically for the replicated tables.

How to use #

Manage this setting using meltano config or an environment variable:

meltano config target-bigquery set schema_mapping '{...}'

export TARGET_BIGQUERY_SCHEMA_MAPPING='{...}'

Add Metadata Columns (add_metadata_columns) #

Metadata columns add extra row level information about data ingestions, (i.e. when was the row read in source, when was inserted or deleted in bigquery etc.) Metadata columns are creating automatically by adding extra columns to the tables with a column prefix sdc. The column names are following the stitch naming conventions documented at https://www.stitchdata.com/docs/data-structure/integration-schemas#sdc-columns. Enabling metadata columns will flag the deleted rows by setting the _sdc_deleted_at metadata column. Without the add_metadata_columns option the deleted rows from singer taps will not be recognisable in BigQuery.

How to use #

Manage this setting using meltano config or an environment variable:

meltano config target-bigquery set add_metadata_columns true

export TARGET_BIGQUERY_ADD_METADATA_COLUMNS=true

Hard Delete (hard_delete) #

When hard_delete option is true then DELETE SQL commands will be performed in BigQuery to delete rows in tables. It’s achieved by continuously checking the _sdc_deleted_at metadata column sent by the singer tap. Due to deleting rows requires metadata columns, hard_delete option automatically enables the add_metadata_columns option as well.

How to use #

Manage this setting using meltano config or an environment variable:

meltano config target-bigquery set hard_delete true

export TARGET_BIGQUERY_HARD_DELETE=true

Data Flattening Max Level (data_flattening_max_level) #

Object type RECORD items from taps can be loaded into VARIANT columns as JSON (default) or we can flatten the schema by creating columns automatically. When value is 0 (default) then flattening functionality is turned off.

How to use #

Manage this setting using meltano config or an environment variable:

meltano config target-bigquery set data_flattening_max_level 0

export TARGET_BIGQUERY_DATA_FLATTENING_MAX_LEVEL=0

Primary Key Required (primary_key_required) #

Log based and Incremental replications on tables with no Primary Key cause duplicates when merging UPDATE events. When set to true, stop loading data if no Primary Key is defined.

How to use #

Manage this setting using meltano config or an environment variable:

meltano config target-bigquery set primary_key_required false

export TARGET_BIGQUERY_PRIMARY_KEY_REQUIRED=false

Validate Records (validate_records) #

Validate every single record message to the corresponding JSON schema. This option is disabled by default and invalid RECORD messages will fail only at load time by BigQuery. Enabling this option will detect invalid records earlier but could cause performance degradation.

How to use #

Manage this setting using meltano config or an environment variable:

meltano config target-bigquery set validate_records true

export TARGET_BIGQUERY_VALIDATE_RECORDS=true

Temp Schema (temp_schema) #

Name of the schema where the temporary tables will be created. Will default to the same schema as the target tables.

How to use #

Manage this setting using meltano config or an environment variable:

meltano config target-bigquery set temp_schema <temp_schema>

export TARGET_BIGQUERY_TEMP_SCHEMA=<temp_schema>

Looking for help? #

If you're having trouble getting the target-bigquery loader to work, look for an existing issue in its repository, file a new issue, or join the Meltano Slack community and ask for help in the #plugins-general channel.

Found an issue on this page? #

This page is generated from a YAML file that you can contribute changes to. Edit it on GitHub!