younifyd
Menu

Bigquery.jobs.query

Runs a BigQuery SQL query synchronously and returns query results if the query completes within a specified timeout.

POST/projects/{projectId}/queries

Use it in a workflow

  1. Add a step and choose the BigQuery connector.
  2. Pick the Bigquery.jobs.query action (under jobs).
  3. Fill in the fields below, then reference the result from later steps as {{bigqueryJobsQuery.response.data}}.

Request

Path parameters

projectIdstringrequired

Project ID of the project billed for the query

Query parameters

altstring

Data format for the response.

One ofjson

fieldsstring

Selector specifying which fields to include in a partial response.

keystring

API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.

oauth_tokenstring

OAuth 2.0 token for the current user.

prettyPrintboolean

Returns response with indentations and line breaks.

quotaUserstring

An opaque string that represents a user for quota purposes. Must not exceed 40 characters.

userIpstring

Deprecated. Please use quotaUser instead.

Request body

Enter the body as JSON in the step's Body field.

connectionPropertiesarray<object>

Connection properties.

keystring

[Required] Name of the connection property to set.

valuestring

[Required] Value of the connection property.

continuousboolean

[Optional] Specifies whether the query should be executed as a continuous query. The default value is false.

createSessionboolean

If true, creates a new session, where session id will be a server generated random id. If false, runs query with an existing session_id passed in ConnectionProperty, otherwise runs query in non-session mode.

defaultDatasetobject
datasetIdstring

[Required] A unique ID for this dataset, without the project name. The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum length is 1,024 characters.

projectIdstring

[Optional] The ID of the project containing this dataset.

dryRunboolean

[Optional] If set to true, BigQuery doesn't run the job. Instead, if the query is valid, BigQuery returns statistics about the job such as how many bytes would be processed. If the query is invalid, an error returns. The default value is false.

kindstring

The resource type of the request.

Default "bigquery#queryRequest"

labelsobject

The labels associated with this job. You can use these to organize and group your jobs. Label keys and values can be no longer than 63 characters, can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter and each label in the list must have a different key.

locationstring

The geographic location where the job should run. See details at https://cloud.google.com/bigquery/docs/locations#specifying_your_location.

maxResultsinteger (uint32)

[Optional] 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.

maximumBytesBilledstring (int64)

[Optional] 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.

parameterModestring

Standard SQL only. Set to POSITIONAL to use positional (?) query parameters or to NAMED to use named (@myparam) query parameters in this query.

preserveNullsboolean

[Deprecated] This property is deprecated.

querystring

[Required] A query string, following the BigQuery query syntax, of the query to execute. Example: "SELECT count(f1) FROM [myProjectId:myDatasetId.myTableId]".

queryParametersarray<object>

Query parameters for Standard SQL queries.

namestring

[Optional] If unset, this is a positional parameter. Otherwise, should be unique within a query.

parameterTypeobject3 fields
parameterValueobject3 fields
requestIdstring

A unique user provided identifier to ensure idempotent behavior for queries. Note that this is different from the job_id. It has the following properties: 1. It is case-sensitive, limited to up to 36 ASCII characters. A UUID is recommended. 2. Read only queries can ignore this token since they are nullipotent by definition. 3. For the purposes of idempotency ensured by the request_id, a request is considered duplicate of another only if they have the same request_id and are actually duplicates. When determining whether a request is a duplicate of the previous request, all parameters in the request that may affect the behavior are considered. For example, query, connection_properties, query_parameters, use_legacy_sql are parameters that affect the result and are considered when determining whether a request is a duplicate, but properties like timeout_ms don't affect the result and are thus not considered. Dry run query requests are never considered duplicate of another request. 4. When a duplicate mutating query request is detected, it returns: a. the results of the mutation if it completes successfully within the timeout. b. the running operation if it is still in progress at the end of the timeout. 5. Its lifetime is limited to 15 minutes. In other words, if two requests are sent with the same request_id, but more than 15 minutes apart, idempotency is not guaranteed.

timeoutMsinteger (uint32)

[Optional] How long to wait for the query to complete, in milliseconds, before the request times out and returns. Note that this is only a timeout for the request, not the query. If the query takes longer to run than the timeout value, the call returns without any results and with the 'jobComplete' flag set to false. You can call GetQueryResults() to wait for the query to complete and read the results. The default value is 10000 milliseconds (10 seconds).

useLegacySqlboolean

Specifies whether to use BigQuery's legacy SQL dialect for this query. The default value is true. If set to false, the query will use BigQuery's standard SQL: https://cloud.google.com/bigquery/sql-reference/ When useLegacySql is set to false, the value of flattenResults is ignored; query will be run as if flattenResults is false.

Default true

useQueryCacheboolean

[Optional] 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. The default value is true.

Default true

json
{
  "connectionProperties": [
    {
      "key": "string",
      "value": "string"
    }
  ],
  "continuous": false,
  "createSession": false,
  "defaultDataset": {
    "datasetId": "string",
    "projectId": "string"
  },
  "dryRun": false,
  "kind": "bigquery#queryRequest",
  "labels": {},
  "location": "string",
  "maxResults": 0,
  "maximumBytesBilled": "string",
  "parameterMode": "string",
  "preserveNulls": false
}

Response

Returns 200 with an object. Read it in later steps with {{bigqueryJobsQuery.response.data.<field>}}.

cacheHitboolean

Whether the query result was fetched from the query cache.

dmlStatsobject
deletedRowCountstring (int64)

Number of deleted Rows. populated by DML DELETE, MERGE and TRUNCATE statements.

insertedRowCountstring (int64)

Number of inserted Rows. Populated by DML INSERT and MERGE statements.

updatedRowCountstring (int64)

Number of updated Rows. Populated by DML UPDATE and MERGE statements.

errorsarray<object>

[Output-only] The first errors or warnings encountered during the running of the job. The final message includes the number of errors that caused the process to stop. Errors here do not necessarily mean that the job has completed or was unsuccessful.

debugInfostring

Debugging information. This property is internal to Google and should not be used.

locationstring

Specifies where the error occurred, if present.

messagestring

A human-readable description of the error.

reasonstring

A short error code that summarizes the error.

jobCompleteboolean

Whether the query has completed or not. If rows or totalRows are present, this will always be true. If this is false, totalRows will not be available.

jobReferenceobject
jobIdstring

[Required] The ID of the job. The ID must contain only letters (a-z, A-Z), numbers (0-9), underscores (_), or dashes (-). The maximum length is 1,024 characters.

locationstring

The geographic location of the job. See details at https://cloud.google.com/bigquery/docs/locations#specifying_your_location.

projectIdstring

[Required] The ID of the project containing this job.

kindstring

The resource type.

Default "bigquery#queryResponse"

numDmlAffectedRowsstring (int64)

[Output-only] The number of rows affected by a DML statement. Present only for DML statements INSERT, UPDATE or DELETE.

pageTokenstring

A token used for paging results.

rowsarray<object>

An object with as many results as can be contained within the maximum permitted reply size. To get any additional rows, you can call GetQueryResults and specify the jobReference returned above.

farray<object>1 fields

Represents a single row in the result set, consisting of one or more fields.

schemaobject
fieldsarray<object>13 fields

Describes the fields in a table.

sessionInfoobject
sessionIdstring

[Output-only] // [Preview] Id of the session.

totalBytesProcessedstring (int64)

The total number of bytes processed for this query. If this query was a dry run, this is the number of bytes that would be processed if the query were run.

totalRowsstring (uint64)

The total number of rows in the complete query result set, which can be more than the number of rows in this single page of results.

json
{
  "cacheHit": false,
  "dmlStats": {
    "deletedRowCount": "string",
    "insertedRowCount": "string",
    "updatedRowCount": "string"
  },
  "errors": [
    {
      "debugInfo": "string",
      "location": "string",
      "message": "string",
      "reason": "string"
    }
  ],
  "jobComplete": false,
  "jobReference": {
    "jobId": "string",
    "location": "string",
    "projectId": "string"
  },
  "kind": "bigquery#queryResponse",
  "numDmlAffectedRows": "string",
  "pageToken": "string",
  "rows": [
    {
      "f": [
        {
          "v": null
        }
      ]
    }
  ],
  "schema": {
    "fields": [
      {
        "categories": {
          "names": [
            "string"
          ]
        },
        "collation": "string",
        "defaultValueExpression": "string",
        "description": "string",
        "fields": [
          {}
        ],
        "maxLength": "string",
        "mode": "string",
        "name": "string",
        "policyTags": {
          "names": [
            "string"
          ]
        },
        "precision": "string",
        "roundingMode": "string",
        "scale": "string"
      }
    ]
  },
  "sessionInfo": {
    "sessionId": "string"
  },
  "totalBytesProcessed": "string"
}

Need more? See the BigQuery guide for connection setup and behaviour shared by every action.