Skip to main content

Google BigQuery

Loader

Google BigQuery is a cloud-based data warehousing and analytics platform. It allows users to store, manage, and analyze large datasets using SQL-like queries, and is designed to handle petabyte-scale datasets with a serverless architecture that only charges for the queries run.

The target-bigquery loader writes data extracted by Meltano into BigQuery tables, supporting several ingestion methods and both denormalized (typed columns) and fixed-schema (single JSON column) loading patterns.

At a glance

PropertyValue
TypeLoader (target)
AuthenticationGoogle service account key (JSON)
Ingestion methodsStorage Write API, Batch Job, GCS Stage, Streaming Insert
LoadingAppend-only, upsert, or overwrite
Data modelDenormalized (typed columns) or fixed schema (JSON column)
BATCH message supportYes, including Arrow-encoded BATCH files

What you can sync

The BigQuery loader writes data extracted by Meltano into tables in the configured Dataset.

  • Each stream gets a table by default using the stream name.
  • Denormalized loading unpacks nested data into a BigQuery schema derived from the tap's JSON schema, converting arrays to repeated fields and records to structs.
  • Without Denormalized, all data is loaded into a single JSON column, which is resilient to schema changes at the cost of query convenience.
  • Method selects the ingestion path: storage_write_api, batch_job, gcs_stage, or streaming_insert.
  • Upsert merges incoming data into existing rows using the stream's key properties; Overwrite replaces existing rows with the incoming data.
  • Generate View can create a BigQuery view that overlays typed access on top of fixed-schema (JSON column) tables.
  • Partition Granularity and Cluster On Key Properties control table partitioning and clustering.

Arrow BATCH support

target-bigquery can ingest BATCH messages whose files are Arrow-encoded (encoding.format: arrow), in addition to the standard jsonl encoding. This lets taps that emit Arrow batches (for example, taps reading directly from columnar sources) load into BigQuery without an intermediate JSON conversion step.

Arrow BATCH ingestion requires:

  • Denormalized set to true — the fixed-schema (JSON column) path does not support Arrow BATCH files.
  • The native BigQuery ADBC driver available at runtime, installed separately (it is not pip-installable). See the ADBC BigQuery driver docs for installation instructions.

If an Arrow BATCH message arrives for a sink that isn't denormalized, or the ADBC driver can't be loaded, the load fails with a descriptive error rather than silently falling back.

Prerequisites

  • A Google Cloud project with the BigQuery API enabled.
  • A BigQuery dataset to load data into. The dataset is not created automatically, so it must already exist before running a pipeline.
  • A Google service account with permissions to create and write to tables in the dataset (for example, roles/bigquery.dataEditor and roles/bigquery.jobUser), and its JSON key.
  • If using gcs_stage, a Google Cloud Storage bucket the service account can write to.

Setup

In Google Cloud

  1. Create or choose a BigQuery dataset in the target project and note its Dataset ID and Location.
  2. Create a service account, or reuse an existing one, and grant it the roles needed to create and write to tables in the dataset.
  3. Create and download a JSON key for the service account.
  4. If you plan to use the gcs_stage method, create a Cloud Storage bucket and grant the service account write access to it.

In Meltano Cloud

  1. Add a new Google BigQuery loader.
  2. Enter the connection details for your BigQuery destination:
    • Service Account Key (json): the full contents of the service account key file
    • Project: the Google Cloud project ID that contains the dataset
    • Dataset: the BigQuery dataset to load into
    • Location: the geographic location of the dataset, if required
    • Method: the ingestion method to use (defaults to Batch Job)
  3. Configure denormalization, upsert/overwrite, and partitioning/clustering settings as needed for your use case.
  4. Once connected, Meltano can use the loader as a destination for pipeline data.

Settings

FieldTypeRequired / DefaultDescription
Service Account Key (json)stringrequiredThe Google Service Account Key JSON object with access to the BigQuery API.
ProjectstringrequiredThe ID of the Google Cloud project that contains the BigQuery dataset to connect to.
DatasetstringrequiredThe name of the BigQuery dataset to connect to.
LocationstringThe geographic location of the BigQuery dataset.
Batch Sizeinteger10000The number of rows to retrieve per API request.
Fail FastbooleanWhether to stop processing if an error occurs during data retrieval.
TimeoutintegerThe maximum amount of time to wait for a response from the API.
DenormalizedbooleantrueWhether to unpack nested data into typed columns rather than a single JSON column. Required for Arrow BATCH ingestion.
Methodoptionsbatch_jobThe ingestion method: storage_write_api, batch_job, gcs_stage, or streaming_insert.
Generate ViewbooleanWhether to create a BigQuery view based on the query results.
BucketstringThe Google Cloud Storage bucket to write query results to. Required for the gcs_stage method.
Partition GranularityoptionsThe level of granularity to use when partitioning query results: year, month, day, or hour.
Cluster On Key PropertiesbooleanWhether to cluster query results based on key properties.
Column Name Transforms LowerbooleanWhether to convert column names to lowercase.
Column Name Transforms QuotebooleanWhether to quote column names.
Column Name Transforms Add Underscore When InvalidbooleanWhether to add an underscore to column names that are invalid.
Column Name Transforms Snake CasebooleantrueWhether to convert column names to snake case.
Options Storage Write Batch ModebooleanThe batch mode to use when writing query results via the Storage Write API.
Options Process PoolbooleanWhether to use worker processes instead of threads for parallel processing.
Options Max WorkersintegerThe maximum number of worker processes to use for parallel processing.
UpsertbooleantrueWhether to update existing rows in the destination table if they match the incoming data.
OverwritebooleanWhether to overwrite existing rows in the destination table with the incoming data.
Dedupe Before UpsertbooleanWhether to remove duplicate rows from the incoming data before performing an upsert.
Stream MapsobjectConfiguration for Stream Maps.
Stream Map ConfigobjectUser-defined configuration values used by map expressions.
Flattening EnabledbooleantrueWhether to flatten nested data structures in the query results.
Flattening Max Depthinteger10The maximum depth of nested data structures to flatten.

Choosing an ingestion method

Batch Job

Loads data using BigQuery load jobs with in-memory compression. Supports both fixed-schema and denormalized loading. This is the default method.

Storage Write API

Uses gRPC and protocol buffers, supporting both streaming and batch patterns. Capable of just-in-time compilation of BigQuery schemas to protobuf, so it can support denormalized loads even when the destination structure is only known at runtime.

GCS Stage

Stages data in a Google Cloud Storage bucket before loading, producing a well-organized data lake alongside the warehouse table. Requires Bucket to be configured.

Streaming Insert

Uses the legacy streaming insert API. Simple and fast to start up and tear down, but generally slower and more costly than the Storage Write API for larger volumes.

Denormalized vs. fixed schema

Denormalized (denormalized: true) unpacks incoming records into a BigQuery schema derived from the tap's JSON schema — arrays become repeated fields, and objects become structs. This is more performant to query and is the recommended setting for taps with a consistent, well-formed schema. It is also required for Arrow BATCH ingestion.

Without denormalization, all data is loaded into a single JSON column. This is more resilient to schema drift and works well for schemaless or rapidly changing sources, at the cost of needing accessor syntax (for example, SELECT data.my_column FROM table) to query individual fields. Generate View can be used to overlay a typed view on top of a fixed-schema table.

Need help?

If you run into an issue not covered here, file it through the usual Meltano support channel with your connection settings (excluding credentials) and the error you're seeing.