get_query_results
Get the results of a BigQuery SQL query job.
Use this tool ONLY when:
A previous
execute_sqlorexecute_sql_readonlycall returnedjobComplete: falsewith ajobId(poll with this tool untiljobComplete: true), ORYou need to paginate through additional rows using
pageTokenorstartIndexfor a previously completed job.
Do NOT call this tool if the query already returned jobComplete: true with all rows (no pageToken).
Supports pagination. Use maxResults to limit results (3,000 by default) and pageToken to retrieve the next page of results.
A response has a pageToken only when more rows are available.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"projectId": "<projectId>",
"jobId": "<jobId>",
"location": "<location>"
},
"name": "get_query_results"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| jobId | Yes | Required. Job ID of the query job. | |
| location | Yes | Required. The geographic location of the job. | |
| pageToken | No | Optional. Page token, returned by a previous call, to request the next page of results. | |
| projectId | Yes | Required. Project ID of the query job. | |
| timeoutMs | No | Optional. Specifies the maximum amount of time, in milliseconds, that the client is willing to wait for the query to complete. | |
| maxResults | No | Optional. Maximum number of results to read. Defaults to 3,000. | |
| startIndex | No | Optional. Zero-based index of the starting row. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rows | No | The rows of this page of results. If `pageToken` is present, more rows are available; see `pageToken`. | |
| jobId | No | Output only. The ID of the BigQuery job created for this query, if any. Present when a query job is created (e.g. for long-running operations, DML, scripts). Use this ID with `get_query_results`, `cancel_job`, or `get_job`. | |
| errors | No | 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. For more information about error messages, see [Error messages](https://cloud.google.com/bigquery/docs/error-messages). | |
| schema | No | The schema of the results. Present only when the query completes successfully. | |
| queryId | No | Output only. The ID of the query. | |
| location | No | Output only. The geographic location of the BigQuery job created for this query, if any. Present when a query job is created (e.g. for long-running operations, DML, scripts). Use this location with `get_query_results`, `cancel_job`, or `get_job`. | |
| pageToken | No | A token for the next page of results. Present only when more rows are available. Pass it to `get_query_results` with `jobId` and `location` to read the next page. | |
| totalRows | No | The total number of rows in the complete query result set, across all pages, so it can be more than the number of rows in `rows`. More rows are available only when `pageToken` is present. | |
| jobComplete | No | 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. | |
| totalSlotMs | No | Output only. Number of slot ms the user is actually billed for. | |
| totalBytesBilled | No | Output only. The total number of bytes billed for the query. Only applies if the project is configured to use on-demand pricing. | |
| numDmlAffectedRows | No | Output only. The number of rows affected by a DML statement. | |
| totalBytesProcessed | No | Output only. The total number of bytes processed for this query. |