Google BigQuery
Connect Cardinal to Google BigQuery to explore datasets and query data using natural language.
Overview
With the BigQuery integration, the AI agent can:
- Explore datasets and tables — browse structure, columns, and types
- Run queries — answer questions about your data using natural language
- Analyze large datasets — leverage BigQuery’s serverless architecture for complex analytical queries
Capabilities
| Capability | Enabled |
|---|---|
| Explore | Always |
| Agent | Always |
Configuration
Settings
| Field | Required | Description |
|---|---|---|
| Project ID | Yes | Google Cloud project ID containing the BigQuery datasets (e.g., my-gcp-project) |
| Dataset | Yes | Default BigQuery dataset. Comma-separated for multiple datasets (e.g., analytics,events) |
Credentials
| Field | Required | Description |
|---|---|---|
| Service Account Key (JSON) | Yes | Full JSON key file for a GCP service account. Paste the entire JSON contents |
Prerequisites
- A Google Cloud project with BigQuery enabled
- A dedicated service account with only these two roles. This is required, not a recommendation. See Service account roles:
- BigQuery Data Viewer (
roles/bigquery.dataViewer) — read access to tables and datasets - BigQuery Job User (
roles/bigquery.jobUser) — permission to run query jobs
- BigQuery Data Viewer (
How Cardinal keeps queries read-only
Version: the enforcement described in this section needs Cardinal UI v1.97.16 or later. Earlier versions check statements less strictly, so the least-privilege role below matters even more on them.
Cardinal only runs read queries against BigQuery. Every query the agent runs goes through these checks:
- Statement check. Cardinal accepts a single
SELECTorWITHstatement. It refuses multiple statements, write and DDL keywords, andINTO. - Dry-run type check. Cardinal first dry-runs the query, which is free and runs nothing. It refuses the query unless BigQuery itself classifies it as a
SELECT. That rejects DML, DDL,EXPORT DATA,CALLand multi-statement scripts however they’re written. - Bytes-billed cap. The real query runs with a maximum-bytes-billed limit, 10 GiB by default. A query that would scan more fails at BigQuery instead of being billed. Narrow the time range or partitions if you hit it.
These checks don’t replace least-privilege roles. The service account’s roles are the final boundary, which is why the next section is required.
Service account roles (required)
Cardinal must connect with a dedicated service account that can only read the datasets you want it to see and run query jobs. Don’t reuse a service account that other systems use. Any Cardinal member or admin, or an agent acting for one, can run queries through this integration, and those queries run with this service account’s permissions.
This applies the same way whether you run Cardinal UI self-hosted in your own VPC or use Cardinal SaaS: in both cases every query runs as the service account whose key you enter under Credentials.
Grant only
roles/bigquery.dataViewer, preferably on each dataset rather than the whole projectroles/bigquery.jobUseron the project that runs the queries
The service account must not have
roles/bigquery.dataEditor,roles/bigquery.dataOwner,roles/bigquery.userorroles/bigquery.admin- Project-level
roles/ownerorroles/editor - Any Cloud Storage write role, which
EXPORT DATAwould need
Example (gcloud)
To use the console instead, see Creating a Service Account below. Replace my-gcp-project and analytics with your project and dataset:
gcloud iam service-accounts create cardinal-bigquery-reader \
--project=my-gcp-project \
--display-name="Cardinal (read-only)"
gcloud projects add-iam-policy-binding my-gcp-project \
--member="serviceAccount:cardinal-bigquery-reader@my-gcp-project.iam.gserviceaccount.com" \
--role="roles/bigquery.jobUser"Then grant read access on each dataset, in BigQuery SQL:
GRANT `roles/bigquery.dataViewer`
ON SCHEMA `my-gcp-project.analytics`
TO "serviceAccount:cardinal-bigquery-reader@my-gcp-project.iam.gserviceaccount.com";Creating a Service Account
- Go to the GCP Console > IAM & Admin > Service Accounts
- Click Create Service Account
- Give it a descriptive name (e.g.,
cardinal-bigquery-reader) - Grant only the roles BigQuery Data Viewer and BigQuery Job User, and nothing else
- Click Done, then select the service account
- Go to the Keys tab and click Add Key > Create new key > JSON
- Download the JSON key file
Setup
- Navigate to Settings > Integrations and click Add Integration
- Select BigQuery
- Enter your Project ID and Dataset name(s)
- Paste the full contents of the Service Account Key JSON file
- Click Test Connection to verify access
- Click Save
What This Enables
Once configured, you can ask the AI agent questions like:
- “What are the top queries by scan volume this week?”
- “Show me daily active users for the last 30 days”
- “List all tables in the analytics dataset”
Reach out to support@cardinalhq.io for support or to ask questions not answered in our documentation.