# Connect BigQuery to Type.com

> Connect Google BigQuery to Type.com with Google sign-in or a service account so AI can explore schemas and run read-only SQL queries.

Canonical page: https://docs.type.com/connectors-and-skills/bigquery/

Connect Google BigQuery to Type.com so AI can list your projects, datasets, and tables, read table schemas, and run read-only SQL queries. You can connect by signing in with a Google account that has BigQuery access, or with a Google Cloud service account. BigQuery is always a **Team** connection.

## Before you start

You need:

- A Google Cloud project with the BigQuery API enabled and billing set up.
- A list of the datasets or tables AI should be able to read.
- To connect from a Space, you need to be a member of that Space.

## Connect BigQuery to Type.com

1. Open the Space that should use BigQuery and go to **Settings → Connections**.
2. Select **Add connection** and choose **Google BigQuery**. If you manage an existing BigQuery connection that isn't in this Space yet, it's listed too; select it to add it here. If someone else manages it, ask them or a workspace admin to add it to this Space.
3. Choose how to connect: **Connect with Google OAuth** or **Connect with service account JSON**.

You can also connect from **Connections** in the sidebar. That creates the connection without adding it to a Space; add it to Spaces afterwards. See [Space Connections](https://docs.type.com/connectors-and-skills/space-connections/index.md).

### Connect with Google OAuth

Use this to connect through a Google account that has access to the BigQuery projects AI should use.

1. Under **Connect with Google OAuth**, select **Connect to Google BigQuery**.
2. Sign in to Google.

Type.com asks Google for read-only BigQuery access. Everyone who can use the connection queries BigQuery as that Google account and sees whatever it can read.

### Connect with service account JSON

Use this for workspace-managed access. You need permission in Google Cloud to create service accounts and keys, and to grant IAM roles on the project and datasets.

Google's guides cover [creating service accounts](https://cloud.google.com/iam/docs/service-accounts-create), [creating service account keys](https://cloud.google.com/iam/docs/keys-create-delete), and [BigQuery IAM roles](https://cloud.google.com/bigquery/docs/access-control).

**Create a service account in Google Cloud**

1. In the Google Cloud console, open [Create service account](https://console.cloud.google.com/projectselector/iam-admin/serviceaccounts/create) and select your project.
2. Enter a name, for example `type-bigquery`, and select **Create and continue**.
3. Grant it **BigQuery Job User** on the project where queries should run. This role lets it run queries in the project. It can only be granted on a project, folder, or organization.
4. Grant it **BigQuery Data Viewer** on the data AI should read: on the project for project-wide access, or on each dataset or table for narrower access.
5. Select **Done**.

If your data is in several projects, grant **BigQuery Job User** on the project that runs the queries, and **BigQuery Data Viewer** on each dataset AI should read.

**Create a JSON key**

1. Open the service account and select the **Keys** tab.
2. Select **Add key**, then **Create new key**.
3. Select **JSON** and select **Create**. The key file downloads. You can't download it again.

Treat the key like a password. If it's exposed, delete it in Google Cloud and create a new key.

**Add the key in Type.com**

1. Under **Connect with service account JSON**, open the key file and copy all of it, including the outer `{ }`.
2. Paste it into **Service account JSON** and select **Connect with service account**.

You see **Google BigQuery connected**, then **Google BigQuery added to this Space**. If the second message is **Could not add Google BigQuery**, add the connection to the Space from **Settings → Connections**.

Type.com checks that you pasted service account JSON with a `client_email` and `private_key`, and stores it encrypted. It doesn't test the key with Google when you save, so check access right away.

## Check access

In a thread in the Space, ask:

1. "List the BigQuery datasets in project `your-project-id`."
2. "Show the schema of `your-project-id.your_dataset.your_table`."
3. "Run a small query on that table, filtered to yesterday's partition."

## How queries work

- **One read-only query at a time.** Each query must begin with `SELECT` or `WITH`. Type.com rejects anything else before it reaches BigQuery.
- **Dry run first.** Before every query, Type.com runs a BigQuery dry run, so permission, name, and syntax errors show up before the query runs.
- **Up to 100 rows.** Type.com returns at most 100 rows per query. A `LIMIT` doesn't reduce how much data a query scans, so use a partition filter on partitioned tables.
- **Up to 1 TB billed per query by default.** A query that would bill more fails without a charge. Whoever manages the connection can lower, raise, or remove this limit. See [Change the query limit](#change-the-query-limit).
- **Project.** AI chooses the project for each query. The query runs in that project.
- **Lists.** Lists of projects, datasets, and tables come in pages of 50 by default. AI can ask for up to 100 per page.

The row limit applies to every BigQuery connection. Each connection has its own billing limit. Asking AI for more doesn't raise either limit.

## Change the query limit

Anyone who manages the connection can change how much data one query can bill. Without granular integration permissions, that's workspace owners, admins, and the person who added the connection. With granular permissions, it's workspace owners, admins, and the connection's designated managers.

1. Open **Settings → Connections** and select the BigQuery connection.
2. Under **Query limit**, select **Edit limit**.
3. Enter the maximum GB billed per query, at least 0.01 GB (10 MB). To let queries bill any amount, select **No limit** instead.
4. Select **Save limit**.

The same people can change the limit without opening settings: ask AI in Type.com to change it, or use [`type-cli integrations settings`](https://docs.type.com/reference/type-cli/index.md#change-a-connection-setting). AI changes the limit only for someone who manages the connection.

A new connection starts at 1,000 GB (1 TB). BigQuery bills queries to your Google Cloud project, so a higher limit or no limit lets one query cost more. The limit applies to each query, not to a day's total. To limit daily spend, set a custom query quota in Google Cloud for the project or for the account Type.com connects as. Each connection has its own limit, so to give one Space a higher limit, add a second BigQuery connection to only that Space and raise its limit.

## Troubleshoot BigQuery

| What you see | What to do |
| --- | --- |
| "Invalid credentials for provider" when you connect | Paste the whole service account JSON key file, including the outer braces. Don't use an OAuth client file or another kind of Google credential file. |
| A 403 permission error. For queries it starts with "BigQuery dry run failed (403)" | Make sure the Google account or service account can run queries in the project (for a service account, **BigQuery Job User**) and read the dataset or table (**BigQuery Data Viewer**). |
| Projects or datasets you expect are missing from lists | They may be on a later page, so ask AI to fetch the next page. Or the connected account may not have access to them: grant access, or give AI the full `project.dataset.table` name. |
| A dataset or table isn't found (404) | Check the project ID, dataset ID, and table name. |
| "Only SELECT queries are allowed" | The query must begin with `SELECT` or `WITH`. |
| "Only one SELECT statement is allowed" | Remove any `;` except one at the very end. Type.com counts a `;` anywhere else as a second statement, even inside quoted text or a comment. |
| "Statement type '...' is not allowed" or "Keyword '...' is not allowed in queries" | The query contains a blocked word, such as `UPDATE`, `SET`, `REPLACE`, `INTO`, or `CALL`, on its own. This includes quoted text, the `REPLACE()` function, and names like `update` or `my-update-project`. Longer names like `updated_at` are fine. Words in `--` and `/* */` comments are ignored, but words in `#` comments are not. Rephrase the query. |
| The query exceeds the bytes billed limit | Add partition filters, select fewer columns, or query a smaller table or view. If the query needs more, an admin can [raise the query limit](#change-the-query-limit). |
| "BigQuery query did not finish after polling; try a narrower query or lower row limit" | Narrow the query with filters, or aggregate first. |
| Results stop at 100 rows | Ask AI to aggregate, or to split the work into several filtered queries. |

## Frequently asked questions

**Can AI change or delete data in BigQuery through Type.com?**
No. The BigQuery connection only has read tools, and Type.com rejects any query that isn't a single `SELECT` or `WITH` statement.

**Does Read-only access in Type.com limit which datasets AI can see?**
No. All BigQuery tools are read-only, so **Full** and **Read-only** behave the same. By default, which projects, datasets, and tables AI can see depends on the connected Google account's or service account's access in Google Cloud.

**Which roles does a service account need?**
**BigQuery Job User** on the project that runs queries, and **BigQuery Data Viewer** on the data AI should read.

**Can I connect BigQuery as a Personal connection?**
No. BigQuery is always a **Team** connection, whichever way you connect.

**How much data can a query return or scan?**
Up to 100 rows per query. By default a query can bill up to 1 TB. Whoever manages the connection can change or remove that limit.
