BigQuery Query

Runs SQL queries against Google BigQuery. Returns results as Arrow RecordBatch.

Configuration

- gcp_bigquery_query:
    name: get_orders
    credentials_path: /etc/gcp/service-account.json
    project_id: my-project
    query: "SELECT * FROM `my-project.dataset.orders` WHERE date = @date"
    parameters:
      date: "{{event.data.date}}"

Fields

FieldTypeDefaultDescription
namestringrequiredTask name.
credentials_pathstringGCP service account credentials. Falls back to Application Default Credentials when omitted.
project_idstringrequiredGCP project ID (data project).
job_project_idstringGCP project ID for billing (if different).
querystring/resourcerequiredSQL query. Supports templating and resource files.
parametersmapNamed query parameters.
locationstringBigQuery location (e.g., US, EU).
max_resultsintMax rows per page.
timeoutduration10sQuery timeout.
use_query_cachebooltrueUse BigQuery query cache.
use_legacy_sqlboolfalseUse legacy SQL syntax.
default_datasetstringDefault dataset for unqualified table names.
labelsmapJob labels.
use_storage_readboolfalseRoute the result through the BigQuery Storage Read API instead of paginated REST results. Recommended for large result sets (over one million rows or one hundred megabytes). Adds temporary-table overhead for smaller queries and is not compatible with data-definition or data-manipulation statements such as INSERT or CREATE TABLE.
depends_onlistUpstream task names.
retryobjectRetry configuration.

Output

The task streams the result and emits one downstream event per wire batch (getQueryResults page for the REST backend, Arrow batch for the Storage Read backend). The final event carries completion_tx so downstream buffers observe end-of-batch even on empty result sets. An empty result set still produces one event containing an empty RecordBatch.

FormatCrateDescription
Arrow RecordBatchgoogle-cloud-bigqueryQuery results with columns and types matching the BigQuery result set. On the REST backend, the job ID is set as event.id on the first emitted event. The Storage Read backend does not surface the parent job ID.

Example: Query with resource file

- gcp_bigquery_query:
    name: daily_report
    credentials_path: /etc/gcp/service-account.json
    project_id: my-project
    query:
      resource: queries/daily_report.sql
    parameters:
      start_date: "{{event.data.start}}"
      end_date: "{{event.data.end}}"