# Google BigQuery (/integrations/google_bigquery)





{/* MANUAL-CONTENT-START:intro */}

[BigQuery](https://cloud.google.com/bigquery) stores and queries datasets with SQL. Use this integration to run queries, inspect datasets, tables, and schemas, and insert rows. Connect the Google credentials required by the selected operation.

{/* MANUAL-CONTENT-END */}

## OAuth scopes [#oauth-scopes]

Sim requests these scopes when someone connects a Google BigQuery account. For a self-hosted deployment, register your own app with the provider using the settings below. See [Integrations and OAuth](/platform/self-hosting/integrations-oauth) for setup.

| Setting | Value |
| - | - |
| Redirect URI | `<NEXT_PUBLIC_APP_URL>/api/auth/oauth2/callback/google-bigquery` |
| Environment variables | `GOOGLE_CLIENT_ID`, `GOOGLE_CLIENT_SECRET` |

| Scope | Description |
| - | - |
| `https://www.googleapis.com/auth/userinfo.email` | View email address |
| `https://www.googleapis.com/auth/userinfo.profile` | View basic profile info |
| `https://www.googleapis.com/auth/bigquery` | View and manage data in Google BigQuery |

## Use the block [#usage-instructions]

Connect to Google BigQuery to run SQL queries, list datasets and tables, get table metadata, and insert rows.

## Actions [#actions]

### BigQuery Run Query [#bigquery-run-query]

Run a SQL query against Google BigQuery and return the results

<ReferenceDetails>
  #### Input [#input]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `projectId` | string | Yes | Google Cloud project ID |
  | `query` | string | Yes | SQL query to execute |
  | `useLegacySql` | boolean | No | Whether to use legacy SQL syntax (default: false) |
  | `maxResults` | number | No | Maximum number of rows to return |
  | `defaultDatasetId` | string | No | Default dataset for unqualified table names |
  | `location` | string | No | Processing location (e.g., "US", "EU") |

  #### Output [#output]

  | Parameter | Type | Description |
  | - | - | - |
  | `columns` | array | Array of column names from the query result |
  | `rows` | array | Array of row objects keyed by column name |
  | `totalRows` | string | Total number of rows in the complete result set |
  | `jobComplete` | boolean | Whether the query completed within the timeout |
  | `totalBytesProcessed` | string | Total bytes processed by the query |
  | `cacheHit` | boolean | Whether the query result was served from cache |
  | `jobReference` | object | Job reference (useful when jobComplete is false) |
  | ↳ `projectId` | string | Project ID containing the job |
  | ↳ `jobId` | string | Unique job identifier |
  | ↳ `location` | string | Geographic location of the job |
  | `pageToken` | string | Token for fetching additional result pages |
</ReferenceDetails>

### BigQuery Get Query Results [#bigquery-get-query-results]

Fetch results for a previously submitted BigQuery job, or the next page of a Run Query result

<ReferenceDetails>
  #### Input [#input-1]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `projectId` | string | Yes | Google Cloud project ID |
  | `jobId` | string | Yes | ID of the BigQuery job to fetch results for |
  | `pageToken` | string | No | Token for pagination |
  | `maxResults` | number | No | Maximum number of rows to return |
  | `timeoutMs` | number | No | How long to wait for the job to complete, in milliseconds |
  | `location` | string | No | Processing location of the job (e.g., "US", "EU") |
  | `startIndex` | string | No | Zero-based index of the starting row |

  #### Output [#output-1]

  | Parameter | Type | Description |
  | - | - | - |
  | `columns` | array | Array of column names from the query result |
  | `rows` | array | Array of row objects keyed by column name |
  | `totalRows` | string | Total number of rows in the complete result set |
  | `jobComplete` | boolean | Whether the job has completed |
  | `totalBytesProcessed` | string | Total bytes processed by the query |
  | `cacheHit` | boolean | Whether the query result was served from cache |
  | `jobReference` | object | Job reference (useful when jobComplete is false) |
  | ↳ `projectId` | string | Project ID containing the job |
  | ↳ `jobId` | string | Unique job identifier |
  | ↳ `location` | string | Geographic location of the job |
  | `pageToken` | string | Token for fetching additional result pages |
</ReferenceDetails>

### BigQuery List Datasets [#bigquery-list-datasets]

List all datasets in a Google BigQuery project

<ReferenceDetails>
  #### Input [#input-2]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `projectId` | string | Yes | Google Cloud project ID |
  | `maxResults` | number | No | Maximum number of datasets to return |
  | `pageToken` | string | No | Token for pagination |

  #### Output [#output-2]

  | Parameter | Type | Description |
  | - | - | - |
  | `datasets` | array | Array of dataset objects |
  | ↳ `datasetId` | string | Unique dataset identifier |
  | ↳ `projectId` | string | Project ID containing this dataset |
  | ↳ `friendlyName` | string | Descriptive name for the dataset |
  | ↳ `location` | string | Geographic location where the data resides |
  | `nextPageToken` | string | Token for fetching next page of results |
</ReferenceDetails>

### BigQuery Create Dataset [#bigquery-create-dataset]

Create a new dataset in a Google BigQuery project

<ReferenceDetails>
  #### Input [#input-3]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `projectId` | string | Yes | Google Cloud project ID |
  | `datasetId` | string | Yes | ID for the new BigQuery dataset |
  | `location` | string | No | Geographic location for the dataset (e.g., "US", "EU") |
  | `friendlyName` | string | No | Human-readable name for the dataset |
  | `description` | string | No | Description of the dataset |

  #### Output [#output-3]

  | Parameter | Type | Description |
  | - | - | - |
  | `datasetId` | string | Unique dataset identifier |
  | `projectId` | string | Project ID containing this dataset |
  | `friendlyName` | string | Descriptive name for the dataset |
  | `description` | string | Dataset description |
  | `location` | string | Geographic location where the data resides |
  | `creationTime` | string | Dataset creation time (milliseconds since epoch) |
</ReferenceDetails>

### BigQuery Delete Dataset [#bigquery-delete-dataset]

Delete a dataset from a Google BigQuery project

<ReferenceDetails>
  #### Input [#input-4]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `projectId` | string | Yes | Google Cloud project ID |
  | `datasetId` | string | Yes | BigQuery dataset ID to delete |
  | `deleteContents` | boolean | No | Whether to delete tables inside the dataset (default: false) |

  #### Output [#output-4]

  | Parameter | Type | Description |
  | - | - | - |
  | `deleted` | boolean | Whether the dataset was deleted |
</ReferenceDetails>

### BigQuery List Tables [#bigquery-list-tables]

List all tables in a Google BigQuery dataset

<ReferenceDetails>
  #### Input [#input-5]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `projectId` | string | Yes | Google Cloud project ID |
  | `datasetId` | string | Yes | BigQuery dataset ID |
  | `maxResults` | number | No | Maximum number of tables to return |
  | `pageToken` | string | No | Token for pagination |

  #### Output [#output-5]

  | Parameter | Type | Description |
  | - | - | - |
  | `tables` | array | Array of table objects |
  | ↳ `tableId` | string | Table identifier |
  | ↳ `datasetId` | string | Dataset ID containing this table |
  | ↳ `projectId` | string | Project ID containing this table |
  | ↳ `type` | string | Table type (TABLE, VIEW, EXTERNAL, etc.) |
  | ↳ `friendlyName` | string | User-friendly name for the table |
  | ↳ `creationTime` | string | Time when created, in milliseconds since epoch |
  | `totalItems` | number | Total number of tables in the dataset |
  | `nextPageToken` | string | Token for fetching next page of results |
</ReferenceDetails>

### BigQuery Get Table [#bigquery-get-table]

Get metadata and schema for a Google BigQuery table

<ReferenceDetails>
  #### Input [#input-6]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `projectId` | string | Yes | Google Cloud project ID |
  | `datasetId` | string | Yes | BigQuery dataset ID |
  | `tableId` | string | Yes | BigQuery table ID |

  #### Output [#output-6]

  | Parameter | Type | Description |
  | - | - | - |
  | `tableId` | string | Table ID |
  | `datasetId` | string | Dataset ID |
  | `projectId` | string | Project ID |
  | `type` | string | Table type (TABLE, VIEW, SNAPSHOT, MATERIALIZED\_VIEW, EXTERNAL) |
  | `description` | string | Table description |
  | `numRows` | string | Total number of rows |
  | `numBytes` | string | Total size in bytes, excluding data in streaming buffer |
  | `schema` | array | Array of column definitions |
  | ↳ `name` | string | Column name |
  | ↳ `type` | string | Data type (STRING, INTEGER, FLOAT, BOOLEAN, TIMESTAMP, RECORD, etc.) |
  | ↳ `mode` | string | Column mode (NULLABLE, REQUIRED, or REPEATED) |
  | ↳ `description` | string | Column description |
  | `creationTime` | string | Table creation time (milliseconds since epoch) |
  | `lastModifiedTime` | string | Last modification time (milliseconds since epoch) |
  | `location` | string | Geographic location where the table resides |
</ReferenceDetails>

### BigQuery Create Table [#bigquery-create-table]

Create a new table in a Google BigQuery dataset

<ReferenceDetails>
  #### Input [#input-7]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `projectId` | string | Yes | Google Cloud project ID |
  | `datasetId` | string | Yes | BigQuery dataset ID |
  | `tableId` | string | Yes | ID for the new BigQuery table |
  | `schema` | string | Yes | JSON array of column field definitions, e.g. \[\{"name":"id","type":"STRING","mode":"REQUIRED"}] |
  | `description` | string | No | Description of the table |
  | `friendlyName` | string | No | Human-readable name for the table |

  #### Output [#output-7]

  | Parameter | Type | Description |
  | - | - | - |
  | `tableId` | string | Table ID |
  | `datasetId` | string | Dataset ID |
  | `projectId` | string | Project ID |
  | `type` | string | Table type (usually TABLE) |
  | `description` | string | Table description |
  | `schema` | array | Array of column definitions |
  | ↳ `name` | string | Column name |
  | ↳ `type` | string | Data type |
  | ↳ `mode` | string | Column mode (NULLABLE, REQUIRED, or REPEATED) |
  | ↳ `description` | string | Column description |
  | `creationTime` | string | Table creation time (milliseconds since epoch) |
  | `location` | string | Geographic location where the table resides |
</ReferenceDetails>

### BigQuery Delete Table [#bigquery-delete-table]

Delete a table from a Google BigQuery dataset

<ReferenceDetails>
  #### Input [#input-8]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `projectId` | string | Yes | Google Cloud project ID |
  | `datasetId` | string | Yes | BigQuery dataset ID |
  | `tableId` | string | Yes | BigQuery table ID to delete |

  #### Output [#output-8]

  | Parameter | Type | Description |
  | - | - | - |
  | `deleted` | boolean | Whether the table was deleted |
</ReferenceDetails>

### BigQuery List Table Data [#bigquery-list-table-data]

Preview rows from a Google BigQuery table without running a query. Pair with Get Table to know the column order.

<ReferenceDetails>
  #### Input [#input-9]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `projectId` | string | Yes | Google Cloud project ID |
  | `datasetId` | string | Yes | BigQuery dataset ID |
  | `tableId` | string | Yes | BigQuery table ID |
  | `maxResults` | number | No | Maximum number of rows to return |
  | `pageToken` | string | No | Token for pagination |
  | `startIndex` | string | No | Zero-based index of the starting row |
  | `selectedFields` | string | No | Comma-separated list of column names to return |

  #### Output [#output-9]

  | Parameter | Type | Description |
  | - | - | - |
  | `rows` | array | Array of rows, each a raw array of column values in schema order |
  | `totalRows` | string | Total number of rows in the table |
  | `pageToken` | string | Token for fetching the next page of results |
</ReferenceDetails>

### BigQuery Insert Rows [#bigquery-insert-rows]

Insert rows into a Google BigQuery table using streaming insert

<ReferenceDetails>
  #### Input [#input-10]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `projectId` | string | Yes | Google Cloud project ID |
  | `datasetId` | string | Yes | BigQuery dataset ID |
  | `tableId` | string | Yes | BigQuery table ID |
  | `rows` | string | Yes | JSON array of row objects to insert |
  | `skipInvalidRows` | boolean | No | Whether to insert valid rows even if some are invalid |
  | `ignoreUnknownValues` | boolean | No | Whether to ignore columns not in the table schema |

  #### Output [#output-10]

  | Parameter | Type | Description |
  | - | - | - |
  | `insertedRows` | number | Number of rows successfully inserted |
  | `errors` | array | Array of per-row insertion errors (empty if all succeeded) |
  | ↳ `index` | number | Zero-based index of the row that failed |
  | ↳ `errors` | array | Error details for this row |
  | ↳ `reason` | string | Short error code summarizing the error |
  | ↳ `location` | string | Where the error occurred |
  | ↳ `message` | string | Human-readable error description |
</ReferenceDetails>
