> ## Documentation Index
> Fetch the complete documentation index at: https://docs.struct.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# BigQuery

> Connect BigQuery for read-only querying during investigations.

Connect BigQuery so Struct Agent can run read-only queries during investigations. Verify the requested dataset access and preserve read-only grants.

## Inspect access and existing connections

Use a claimed workspace with permission to configure connections.

```bash theme={null}
struct whoami --json
struct connections catalog bigquery --json
struct connections list --json
```

Use the catalog's current fields, choices and permission requirements. Reuse an existing healthy connection instead of creating a duplicate.

## Connect with the CLI

Supply credentials from approved secret storage through `BIGQUERY_CREDENTIALS_JSON`. The catalog describes which are needed for the selected authentication method. Do not put literal secrets in shell arguments or chat.

Replace example values with the intended resource:

```bash theme={null}
struct connect bigquery --project <project-id> --key-file <key-file>
```

Use a dedicated service account with read access to the selected data. Supply its JSON key with `--key-file` or `GOOGLE_APPLICATION_CREDENTIALS`; keep the file outside source control. BigQuery requires the Pro plan. Struct rejects project-level BigQuery write access when its check can verify it. `--dataset` and `--location` are optional.

## Verify and recover

Use the returned connection ID:

```bash theme={null}
struct connections show CONNECTION_ID --json
struct connections test CONNECTION_ID --json
```

Inspect `ok`, `health` and missing permissions, not only the exit code. `struct connections grant-command CONNECTION_ID` prints repair instructions where supported; have an authorized operator apply them. For expired OAuth links, start the connection command again and use the new link. Do not reconnect to a different account silently.

Verify a bounded operation for the requested job. Connection health proves checked access; it does not prove telemetry arrival, an investigation or alert delivery.

## What Struct does with it

Answers data questions during investigations and measures the impact of [Issues](https://docs.struct.ai/agent/jobs/issues.md) with live queries you can inspect.

## Permissions

The service account needs the BigQuery Data Viewer and Job User roles, plus BigQuery Connection User if you query through BigQuery Connections. The setup command grants all three.

### Read-only queries

Run read-only SQL during investigations and measure the impact of open issues.

| Granted by | Used for |
| - | - |
| **BigQuery Data Viewer** (`roles/bigquery.dataViewer`) | Reading tables |
| **BigQuery Job User** (`roles/bigquery.jobUser`) | Running query jobs |

### BigQuery Connections

Only if you query through BigQuery Connections (federated queries to Cloud SQL, Postgres and others).

Granted by: **BigQuery Connection User** (`roles/bigquery.connectionUser`).

* Struct rejects project-level BigQuery write permissions when its connection check can verify them.
* The setup command grants BigQuery Data Viewer on the whole project. To limit Struct to the datasets you choose, grant Data Viewer on those datasets instead. Job User stays at the project level.

### How to grant

> [accordion] Grant the roles
>
> ```bash theme={null}
> gcloud projects add-iam-policy-binding <project-id> --member "serviceAccount:<service-account-email>" --role roles/bigquery.dataViewer &&
> gcloud projects add-iam-policy-binding <project-id> --member "serviceAccount:<service-account-email>" --role roles/bigquery.jobUser &&
> gcloud projects add-iam-policy-binding <project-id> --member "serviceAccount:<service-account-email>" --role roles/bigquery.connectionUser
> ```

Replace the values in angle brackets.

Permission catalog version `2026-11-04.1`. See [permission changes](https://docs.struct.ai/reference/permission-changes.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.