Skip to main content

Google BigQuery ExecModule

Overview

GoogleBigQueryModule connects ValkyrAI workflows to the Google BigQuery REST API through the native map I/O ExecModule ABI. It covers dataset and table discovery, GoogleSQL queries, paged query results, streaming inserts, and guarded table deletion without exposing OAuth credentials to workflow data.

The connector constructs only the fixed bigquery.googleapis.com API host. It retries bounded GET reads, but query submissions, streaming inserts, and deletes receive one attempt because a lost response can make their outcome ambiguous.

Usage

  1. Enable the BigQuery API in the target Google Cloud project.
  2. Create a dedicated service identity or OAuth principal with only the required dataset and job permissions.
  3. Store the Google Cloud project ID in IntegrationAccount.accountId and a short-lived OAuth access token in the encrypted apiKey SecureField.
  4. Set the account to READY and bind it through ExecModuleConfig.authConfig.integrationAccount.
  5. Use discovery operations before targeting a dataset or table, and use query parameters for values.
  6. Set confirmWrite: true for non-read SQL or streaming inserts. Table deletion separately requires confirmDelete: true.

Workflow input cannot supply a credential, authorization header, arbitrary API host, legacy SQL mode, or multiple statements.

Inputs

NameTypeRequirementDefaultDescription and constraints
operationstringRequiredNoneOne of the seven documented operations.
projectIdstringOptionalIntegrationAccount.accountIdGoogle Cloud project ID. A configured override is validated.
datasetIdstringTable operationsNoneBigQuery dataset identifier.
tableIdstringSingle-table operationsNoneBigQuery table identifier.
querystringrun_queryNoneOne GoogleSQL statement, at most 100,000 characters. Multiple statements are rejected.
queryParametersarrayOptional query bindingNoneUp to 1,000 BigQuery {name?,parameterType,parameterValue} objects, capped at 256 KiB.
parameterModestringWith parametersNAMEDNAMED or POSITIONAL.
rowsarrayinsert_rowsNone1–500 non-empty JSON objects, with a total request cap of 1 MiB.
jobIdstringget_query_resultsNoneBigQuery query job ID.
locationstringRegional query jobsNoneValid BigQuery location, such as US, EU, or us-west2.
pageTokenstringOptional continuationNoneOpaque provider token, maximum 4,096 characters.
maxResultsintegerOptional1000Maximum normalized resources or rows, 1–10,000.
timeoutMsintegerOptional30000Provider/query and HTTP timeout, 100–300,000 ms.
requestIdUUID stringStreaming insertsNoneCaller-owned UUID used to derive stable per-row insertId values.
dryRunbooleanrun_queryfalseValidates GoogleSQL and estimates bytes without running it.
skipInvalidRowsbooleanStreaming insertfalseAllows valid rows to commit when another row fails.
ignoreUnknownValuesbooleanStreaming insertfalseIgnores input fields missing from the table schema.
confirmWritebooleanMutation guardfalseRequired for non-read SQL and streaming inserts.
confirmDeletebooleanDestructive guardfalseRequired for delete_table.

Outputs

NameTypeWhen presentDescription
statusstringAlwayssuccess or error.
operationstringAlwaysNormalized operation.
httpStatus / attemptsintegerProvider requestHTTP status and attempts consumed.
items / countarray / integerLists and query rowsBounded resources or rows mapped by returned schema field name.
dataobjectResource or receiptProvider table resource, insert receipt, query dry-run receipt, or other non-row response.
jobId / jobCompletestring / booleanQuery responseQuery continuation identity and completion state.
nextPageTokenstringMore resultsOpaque provider continuation token.
totalRows / cacheHitstring / booleanQuery responseProvider row count and cache status.
errorobjectFailureSafe {code,message,httpStatus?,retryable} details.

OAuth tokens and authorization values are redacted from outputs, errors, logs, and workflow events.

IntegrationAccount Requirements

SettingRequirement
ProviderGoogle Cloud principal with BigQuery API access
accountNameHuman-readable automation identity
accountIdGoogle Cloud project ID, for example valkyrlabs-analytics
apiKeyEncrypted SecureField containing a short-lived OAuth access token
statusExactly READY

For discovery, grant only metadata/list permissions. Query execution typically needs bigquery.jobs.create plus read access to the selected datasets. Streaming inserts need table update-data permission. Table deletion needs table delete permission and should use a separate, narrowly scoped identity when practical. Token issuance and rotation remain IntegrationAccount lifecycle responsibilities.

Configuration

{
"version": "1.0.0",
"authConfig": {
"authStrategy": 1,
"integrationAccount": "integration-account:bigquery-analytics"
},
"retryPolicy": {
"maxAttempts": 3,
"backoffStrategy": "EXPONENTIAL",
"initialDelayMs": 1000,
"maxDelayMs": 60000
},
"payloadConfig": {
"parameters": "{\"operation\":\"run_query\",\"location\":\"US\",\"maxResults\":100}"
}
}

The integration-account reference is symbolic. Persisted workflows use the generated relationship and never plaintext access tokens.

Operations

OperationBigQuery behaviorSide effect
list_datasetsLists all visible datasets in the selected project.Read-only; bounded retry.
list_tablesLists tables in one dataset.Read-only; bounded retry.
get_tableReads one table resource and schema.Read-only; bounded retry.
run_querySubmits one Standard SQL query with optional typed parameters.Read query or confirmed SQL mutation; single attempt.
get_query_resultsReads one page for a query job, optionally in a regional location.Read-only; bounded retry.
insert_rowsSends up to 500 JSON rows through tabledata.insertAll with deterministic insert IDs.Write; confirmed, single attempt.
delete_tableDeletes one dataset table.Destructive; confirmed, single attempt.

Errors and Failure Modes

CodeTypical causeRetryableResolution
VALIDATION_ERRORMissing resource, invalid project/identifier/token/parameter, multiple SQL statements, absent confirmation, or oversized payload.NoCorrect the named input; no request was sent.
UNSUPPORTED_OPERATIONUnknown operation.NoSelect a documented operation.
INTEGRATION_ACCOUNT_REQUIREDNo bound account.NoBind a Google BigQuery IntegrationAccount.
INTEGRATION_ACCOUNT_NOT_READYAccount is not READY.NoRepair or reconnect the account.
BIGQUERY_AUTHERROR / BIGQUERY_HTTP_401Expired or invalid OAuth access token.NoRefresh the IntegrationAccount token.
BIGQUERY_ACCESSDENIED / BIGQUERY_HTTP_403The identity lacks project, dataset, job, table, or row permission.NoGrant only the missing minimum permission.
BIGQUERY_NOTFOUND / BIGQUERY_HTTP_404Project, dataset, table, job, or location is wrong.NoVerify the exact resource and job location.
BIGQUERY_RATELIMITEXCEEDED / BIGQUERY_HTTP_429Provider quota or concurrency limit.GET reads onlyHonor backoff; reconcile write/query state before manual retry.
BIGQUERY_HTTP_5xxTransient provider failure.GET reads onlyRetry reads; do not blindly repeat an ambiguous POST or DELETE.
NETWORK_ERRORTimeout, DNS, TLS, or connectivity failure.GET reads onlyVerify connectivity and reconcile job, insert, or table state.
RESPONSE_TOO_LARGEResponse exceeded 10 MiB.NoReduce maxResults, narrow the query, or request another page.

BigQuery may return successful HTTP status with row-level insertErrors; these remain in data and must be treated as partial failure when skipInvalidRows is enabled.

Example

Run a parameterized lead query:

{
"operation": "run_query",
"query": "SELECT id, name FROM `analytics.leads` WHERE score >= @score ORDER BY score DESC LIMIT 100",
"queryParameters": [
{
"name": "score",
"parameterType": {"type": "INT64"},
"parameterValue": {"value": "80"}
}
],
"parameterMode": "NAMED",
"location": "US",
"maxResults": 100
}

Expected result:

{
"status": "success",
"operation": "run_query",
"httpStatus": 200,
"jobId": "job_analytics_20260810",
"jobComplete": true,
"count": 2,
"items": [
{"id": "42", "name": "Northstar"},
{"id": "77", "name": "Valkyr"}
],
"attempts": 1
}

Notes

  • Pagination: dataset/table lists and query results return nextPageToken. Pass it back unchanged with the same project, resource, job, location, and page size. The connector retrieves one bounded page per invocation.
  • Rate limits: only GET reads retry HTTP 408, 429, 500, 502, 503, and 504 with bounded exponential backoff and Retry-After support. POST query/insert and DELETE table calls always receive one attempt.
  • API limits: requests are capped at 1 MiB, responses at 10 MiB, inserts at 500 rows, query parameters at 1,000 entries/256 KiB, and normalized output at 10,000 items.
  • Idempotency: streaming inserts require a caller UUID and derive insertId as <requestId>:<row-index>. BigQuery offers best-effort insert deduplication, not a transaction receipt; reconcile table data before repeating an ambiguous call.
  • Destructive behavior: delete_table is irreversible through this module and requires confirmDelete: true. Dataset deletion, model/routine deletion, partition expiration changes, IAM changes, load/copy/extract jobs, and job cancellation are intentionally deferred.
  • SQL safety: SELECT, WITH, and EXPLAIN run without a mutation confirmation; every other prefix requires confirmWrite. This is a guard, not a SQL parser or substitute for provider IAM, authorized views, row-level security, policy tags, or reservations.
  • Authentication: the module accepts OAuth bearer tokens only. Service-account private keys, refresh tokens, and arbitrary API bases are intentionally unsupported in workflow payloads.
  • API behavior: nested and repeated query cells remain provider-shaped JSON inside the normalized field value. Consumers needing typed nested expansion should apply a downstream mapper.
  • External verification: local tests verify validation, fixed-host routing, OAuth headers, query parameters, pagination, row normalization, retries, mutation guards, insert IDs, redaction, and metadata discovery. Live Google Cloud IAM, billing, quotas, locations, reservations, table schemas, streaming consistency, and SQL execution require separately authorized provider credentials and are not exercised in repository tests.
  • Functional references: n8n Google BigQuery integration, BigQuery REST v2, parameterized queries, and streaming inserts.