
Google Cloud Query
CertifiedExecute a BigQuery SQL job
Google Cloud Query
Execute a BigQuery SQL job
Runs a SQL statement with standard SQL by default, optionally writing into a destination table. Supports cache usage, priority selection, schema updates, and deprecated fetch/store outputs (superseded by fetchType). Uses task-level project, service account, and scopes.
type: io.kestra.plugin.gcp.bigquery.QueryExamples
Create a table with a custom query
id: gcp_bq_query
namespace: company.team
tasks:
- id: query
type: io.kestra.plugin.gcp.bigquery.Query
destinationTable: "my-project.my_dataset.my_table"
writeDisposition: WRITE_APPEND
sql: |
SELECT
"hello" as string,
NULL AS `nullable`,
1 as int,
1.25 AS float,
DATE("2008-12-25") AS date,
DATETIME "2008-12-25 15:30:00.123456" AS datetime,
TIME(DATETIME "2008-12-25 15:30:00.123456") AS time,
TIMESTAMP("2008-12-25 15:30:00.123456") AS timestamp,
ST_GEOGPOINT(50.6833, 2.9) AS geopoint,
ARRAY(SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3) AS `array`,
STRUCT(4 AS x, 0 AS y, ARRAY(SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3) AS z) AS `struct`
Execute a query and fetch results sets on another task
id: gcp_bq_query
namespace: company.team
tasks:
- id: fetch
type: io.kestra.plugin.gcp.bigquery.Query
fetch: true
sql: |
SELECT 1 as id, "John" as name
UNION ALL
SELECT 2 as id, "Doe" as name
- id: use_fetched_data
type: io.kestra.plugin.core.debug.Return
format: |
{% for row in outputs.fetch.rows %}
id : {{ row.id }}, name: {{ row.name }}
{% endfor %}
Properties
allowLargeResults booleanstring
Sets whether the job is enabled to create arbitrarily large results
If true the query is allowed to create large results at a slight cost in performance. destinationTable must be provided.
clusteringFields array
The clustering specification for the destination table
createDisposition string
CREATE_IF_NEEDEDCREATE_NEVERCreate disposition
Whether the job may create the destination table
defaultDataset string
Sets the default dataset
This dataset is used for all unqualified table names used in the query.
destinationTable string
Destination table
Table to receive job output; creation depends on createDisposition
dryRun booleanstring
falseDry run
If true, validates the job and returns statistics without running it
fetchType string
NONESTOREFETCHFETCH_ONENONEResult handling mode
NONE by default. Use FETCH or STORE to make results available to downstream tasks; prefer over deprecated fetch/store flags.
flattenResults booleanstring
trueSets whether nested and repeated fields should be flattened
If set to false, allowLargeResults must be true.
impersonatedServiceAccount string
The GCP service account to impersonate
jobTimeout string
Job timeout
Optional max duration; BigQuery may terminate the job when exceeded
labels object
Job labels
legacySql booleanstring
falseUse legacy SQL
Default false; when true, runs the query with the legacy dialect
location string
Dataset location
Optional BigQuery location for created or targeted resources. Experimental and may change; see BigQuery dataset location documentation.
maxResults integerstring
This is only supported in the fast query path
The maximum number of rows of data to return per page of results. Setting this flag to a small value such as 1000 and then paging through results might improve reliability when the query result set is large. In addition to this limit, responses are also limited to 10 MB. By default, there is no maximum row count, and only the byte limit applies.
maximumBillingTier integerstring
Limits the billing tier for this job
Queries that have resource usage beyond this tier will fail (without incurring a charge). If unspecified, this will be set to your project default.
maximumBytesBilled integerstring
Limits the bytes billed for this job
Queries that will have bytes billed beyond this limit will fail (without incurring a charge). If unspecified, this will be set to your project default.
pluginDefaultsRef Non-dynamicstring
Reference (ref) of the pluginDefaults to apply to this task.
priority string
INTERACTIVEINTERACTIVEBATCHQuery priority
INTERACTIVE by default; choose BATCH to queue if slots are unavailable
projectId string
The GCP project ID
rangePartitioningEnd integerstring
The end range partitioning, inclusive
rangePartitioningField string
Range partitioning field for the destination table
rangePartitioningInterval integerstring
The width of each interval
rangePartitioningStart integerstring
The start of range partitioning, inclusive
retryAuto Non-dynamic
Automatic BigQuery retry policy
Optional custom retry policy for retryable BigQuery errors. If unset, uses an exponential backoff starting at 5s, up to 15m, max 10 attempts.
Constant retry
Retry with a fixed delay between attempts.
durationRETRY_FAILED_TASKRETRY_FAILED_TASKCREATE_NEW_EXECUTION>= 1durationfalseExponential retry
Retry with exponentially increasing delays between attempts.
durationdurationRETRY_FAILED_TASKRETRY_FAILED_TASKCREATE_NEW_EXECUTION>= 1durationfalseRandom retry
Retry with a random delay within a configurable range between attempts.
durationdurationRETRY_FAILED_TASKRETRY_FAILED_TASKCREATE_NEW_EXECUTION>= 1durationfalseretryMessages array
["due to concurrent update","Retrying the job may solve the problem","Retrying may solve the problem"]Retry message substrings
Case-insensitive substrings that, if found in the error message, trigger an automatic retry
retryReasons array
["rateLimitExceeded","jobBackendError","backendError","internalError","jobInternalError"]Retry reasons
BigQuery error reasons that trigger an automatic retry; evaluated against error reason strings
schemaUpdateOptions array
ALLOW_FIELD_ADDITIONALLOW_FIELD_RELAXATION[Experimental] Options allowing the schema of the destination table to be updated as a side effect of the query job
Schema update options are supported in two cases: * when writeDisposition is WRITE_APPEND;
- when writeDisposition is WRITE_TRUNCATE and the destination table is a partition of a table, specified by partition decorators. For normal tables, WRITE_TRUNCATE will always overwrite the schema.
scopes array
["https://www.googleapis.com/auth/cloud-platform"]The GCP scopes to be used
serviceAccount string
The GCP service account
sql string
SQL query
Rendered SQL string to execute; uses standard SQL unless legacySql is true
timePartitioningField string
The time partitioning field for the destination table
timePartitioningType string
DAYDAYHOURMONTHYEARThe time partitioning type specification
useLegacySql booleanstring
falseSets whether to use BigQuery's legacy SQL dialect for this query
A valid query will return a mostly empty response with some processing statistics, while an invalid query will return the same error it would if it wasn't a dry run.
useQueryCache booleanstring
Sets whether to look for the result in the query cache
The query cache is a best-effort cache that will be flushed whenever tables in the query are modified. Moreover, the query cache is only available when destinationTable is not set
writeDisposition string
WRITE_TRUNCATEWRITE_TRUNCATE_DATAWRITE_APPENDWRITE_EMPTYWrite disposition
Action when destination exists
Outputs
destinationTable
The destination table (if one) or the temporary table created automatically
io.kestra.plugin.gcp.bigquery.Query-DestinationTable
The dataset of the table
The project of the table
The table name
jobId string
The job id
row object
Map containing the first row of fetched data
Only populated if 'fetchOne' parameter is set to true.
rows array
List containing the fetched data
Only populated if 'fetch' parameter is set to true.
size integer
The size of the rows fetch
uri string
uriThe uri of store result
Only populated if 'store' is set to true.
Metrics
cache.hit counter
Whether the query result was fetched from the query cache.
duration timer
The time it took for the query to run.
estimated.bytes.processed counter
bytesThe original estimate of bytes processed for the query.
num.child.jobs counter
The number of child jobs executed by the query.
num.dml.affected.rows counter
recordsThe number of rows affected by a DML statement. Present only for DML statements INSERT, UPDATE or DELETE.
referenced.tables counter
The number of tables referenced by the query.
total.bytes.billed counter
bytesThe total number of bytes billed for the query.
total.bytes.processed counter
bytesThe total number of bytes processed by the query.
total.partitions.processed counter
partitionsThe totla number of partitions processed from all partitioned tables referenced in the job.
total.slot.ms counter
The slot-milliseconds consumed by the query.