docs/guides/bigquery.md
This guide shows how to add a BigQuery connection in Chat2DB Community and run your first query.
BigQuery is a fully managed cloud data warehouse from Google. Chat2DB connects to it through the Simba JDBC driver and authenticates using a Google Cloud service account.
Before you start, you need:
roles/bigquery.user (BigQuery User) on the project used to run query jobs. To query existing tables, it also needs a data-access role such as roles/bigquery.dataViewer (BigQuery Data Viewer) on the datasets it may read.You do not need a Java or Maven setup to follow this guide. Chat2DB downloads the JDBC driver on first connection.
The service account is what Chat2DB uses to authenticate to BigQuery. Treat its JSON key like a password.
Before you start, your user account needs the Service Account Key Admin role (roles/iam.serviceAccountKeyAdmin) on the project, per the Google Cloud IAM documentation. Your organization may also enforce a policy that disables key creation; if so, follow the policy override steps in the same page.
The official Google Cloud documentation sends you through a guided console walkthrough rather than enumerating each step inline, because the console UI changes over time. The current path is roughly:
chat2db-reader, and click Create and continue.roles/bigquery.user) on the project used to run query jobs, then click Continue and Done..json.~/.config/chat2db-community/keys/.To query tables, grant the service account BigQuery Data Viewer (roles/bigquery.dataViewer) on each dataset it should read. BigQuery User can create query jobs, but it does not by itself grant permission to read table data. See Google's BigQuery access-control documentation for narrower custom-role options.
If your console layout looks different, follow the official walkthrough instead — it always reflects the current UI.
Do not commit this file to any repository, and do not paste its contents into chat, screenshots, or issue trackers. If the file leaks, delete the key in Google Cloud and create a new one.
In Chat2DB, open the connection dialog and choose BigQuery as the database type. The form shows the fields below. Every field is taken from the current Community plugin defaults at chat2db-community-server/chat2db-community-plugins/chat2db-community-bigquery/src/main/resources/ai/chat2db/plugin/bigquery/bigquery.json and the field wiring in BigQueryDBManager.java.
| Field | What to enter | Notes |
|---|---|---|
| URL | jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443 | Pre-filled by the plugin. Leave as the default unless your network requires a proxy. |
| Project | Your GCP project ID | The project used to run and bill query jobs. Data may live in another project when the service account has access to it. |
The service account's client_email | You can find it inside the JSON key file under the client_email field. | |
| Keyfile | Absolute path to the JSON key file | The path must be readable by the Chat2DB backend process, not merely by the browser. Chat2DB passes it to the JDBC driver as OAuthPvtKeyPath. |
| Dataset | Optional | This is currently labelled Datatset in the connection form. It is not translated into a BigQuery authentication property; leave it blank and use fully qualified table names if you are unsure. |
The plugin translates your input to the following JDBC properties before opening the connection:
ProjectId from the Project field.OAuthServiceAcctEmail from the Email field.OAuthType=0 and OAuthPvtKeyPath from the Keyfile field. The OAuthType=0 value selects service-account authentication in the Simba driver.Chat2DB Community ships support for the service account flow only. OAuth user flows (browser sign-in, OAuth refresh tokens) are not currently wired up in the Community plugin, so this guide does not document them.
The Simba driver opens the keyfile from the filesystem of the process running the Chat2DB backend:
-v /absolute/host/path/bigquery.json:/run/secrets/bigquery.json:ro to docker run, then use /run/secrets/bigquery.json as Keyfile.The saved datasource contains the path, not a copy of the JSON credential. Chat2DB does not encrypt or manage the keyfile itself, so keep the file outside the repository and restrict its filesystem permissions.
Click Test connection in the dialog. A success message confirms that the driver downloaded, the service account authenticated, and the project is reachable.
To run the cheapest safe query once the connection is saved, open a new SQL tab and run:
SELECT 1 AS ok;
This query does not read any tables, does not scan data, and does not require any dataset to exist. It processes essentially zero bytes, which puts it inside BigQuery's free tier, so it does not bill the project.
BigQuery uses backtick-quoted fully qualified table names of the form `project.dataset.table`. A useful first query is to list tables in a dataset:
SELECT table_name
FROM `your-project.your_dataset.INFORMATION_SCHEMA.TABLES`
ORDER BY table_name
LIMIT 50;
Replace your-project with your GCP project ID and your_dataset with a dataset the service account can read. To run the query, press Run or use the keyboard shortcut configured in Chat2DB.
These are the failures users hit most often when connecting Chat2DB Community to BigQuery. Each fix is based on either the plugin's own configuration (bigquery.json) or the way the plugin maps form fields to JDBC properties (BigQueryDBManager.java). The exact error text returned by the Simba driver and Google APIs can vary between versions, so match by category rather than verbatim wording.
The Simba JDBC driver archive is downloaded the first time Chat2DB talks to a BigQuery connection. If the runtime cannot reach cdn.chat2db-ai.com, the download fails and the connection cannot open. Allow that host, then click Test connection again. The driver archive filename is SimbaJDBCDriverforGoogleBigQuery42_1.6.1.1002.zip and the driver class is com.simba.googlebigquery.jdbc42.Driver, both defined in bigquery.json.
The service account may be missing roles/bigquery.user on the query project, or it may lack roles/bigquery.dataViewer (or equivalent permissions) on the dataset being queried. Re-check both the Project field and the dataset-level access grant.
The Keyfile value is wrong or is not visible to the backend process. The plugin passes it straight to the JDBC property OAuthPvtKeyPath, which the Simba driver treats as a path to a JSON file. Confirm the path is absolute, the file exists on the backend or inside the container, the process can read it, and you have not edited the JSON by hand.
The Project field does not match the project ID used for query jobs, or the BigQuery API is not enabled for that project. If the project is brand new, confirm whether billing is linked or whether you want to use the BigQuery sandbox without one.
BigQuery normally requires a billing account to be linked to the project. If you prefer to skip billing, the BigQuery sandbox lets you run queries against up to 10 GiB of free storage and 1 TiB of free query processing per month, without attaching a billing account. Either way, queries that scan data still cost the project once the free tier is exhausted. Open Billing for the project in Google Cloud and link an active billing account if you need to go beyond the sandbox limits.
googleapis.comThe Chat2DB backend cannot reach Google APIs. Check DNS, proxy, firewall, and outbound HTTPS access from the backend host or container; testing access in the browser alone does not verify the backend network path.
chmod 600.roles/bigquery.user for query-job creation and grant roles/bigquery.dataViewer only on datasets that it needs to read. Use roles/bigquery.dataEditor only when writes are required.