For the complete documentation index, see llms.txt. This page is also available as Markdown.

BigQuery

Connect Google BigQuery to Algenta — create a bigquery connector with project and service-account credentials, test it, browse datasets, and run a governed query.

This guide creates a bigquery connector, tests the connection, browses the project's datasets and tables, registers a table as a dataset, and runs a governed query against it. A connector is a configured connection to an external system; it backs a queryable source or dataset.

BigQuery reaches Algenta through the standard connector lifecycle: create → test → browse → connect → query. A connector must pass its /test before you can browse it, and you register a dataset before you query.

Before you start

You need:

  • An Algenta API key (see Authentication).

  • A Google Cloud project ID.

  • A service account JSON key with read access to the BigQuery datasets you want to query (the BigQuery Data Viewer and BigQuery Job User roles cover read and query).

Export your key so the examples can read it.

export ALGENTA_API_KEY="$ALGENTA_API_KEY"
export ALGENTA_API_URL="https://api.algenta.ai"

BigQuery support requires the google-cloud-bigquery library on the server. A self-hosted deployment that is missing it returns a clear invalid_config message asking you to install it. Algenta's hosted API ships with it preinstalled.

Config fields

The bigquery connector reads these config keys:

Field
Required
Description

project_id

Yes

The Google Cloud project that owns the datasets, for example my-analytics-project.

service_account_json

For private projects

The service account key — either the inline JSON string or the parsed JSON object. Authenticates the connection.

connection_string

Alternative

A bigquery://PROJECT_ID DSN. Supply this instead of project_id if you prefer a single DSN; the project is parsed from it.

If you provide neither service_account_json nor connection_string, the connector falls back to the server's ambient Google credentials (for example a workload identity attached to the deployment). On most setups you should pass an explicit service account.

Create the connector

POST /v1/connectors stores the connection name, type, and credentials, and returns the connector with status: "untested". Pass the service account JSON as a string in config.service_account_json.

The response includes the id you use for the test, browse, and connect steps.

Test the connection

POST /v1/connectors/{id}/test makes a real connection attempt: it lists one dataset in the project. On success the connector flips to live; on failure it flips to error with a message. Browsing requires a live connector, so always test first.

Expected result. The connector flips to live, and a successful response reports the reachable project:

If credentials are wrong or the project is unreachable, success is false, status is error, and message describes the failure. See Errors for the failure-type taxonomy.

Browse datasets and tables

GET /v1/connectors/{id}/browse lists the datasets and tables visible to the connector. Browsing returns 409 not_connected unless the connector is live, so run /test first.

The response lists the queryable entities the project exposes:

BigQuery tables are addressed as DATASET.TABLE (for example sales.orders). Pick one to register as a dataset in the next step.

Connect a dataset

POST /v1/data/connect ties a connection to a selection — a table or a SQL query — and registers the result as a queryable dataset (governed data). Reference the saved connector by connection_id, and name the table in selection.

When the selection fully identifies one table, the response has status: "ready" with a dataset_id and a schema_summary (row and column counts):

If the connection resolves to more than one table, the response is status: "needs_selection" with a choices array and a connection_id to reuse — pick one selection from choices and call /v1/data/connect again with that connection_id.

Query the dataset

With a dataset_id you run a deterministic, schema-checked query through POST /v1/query. This is the governed-query path: results are validated against the inferred schema and are reproducible.

See Run a governed query for the full query grammar (select, filters, operators, aggregation), and First query for an end-to-end walk-through.

Using a DSN instead of a project ID

If you maintain connection strings centrally, supply connection_string instead of project_id. Algenta parses the project from the bigquery:// DSN.

The DSN must name a project (bigquery://PROJECT_ID). A connector with neither connection_string nor project_id is rejected with missing_connection_string.

Troubleshooting

  • 409 not_connected when browsing. The connector is not live. Run POST /v1/connectors/{id}/test first; only a connector that passes its test can be browsed.

  • invalid_config mentioning google-cloud-bigquery. A self-hosted server is missing the BigQuery client library. Install it with pip install google-cloud-bigquery and restart the API.

  • Test fails with a credentials or permission error. Confirm the service account JSON is valid and that it has read access (BigQuery Data Viewer) plus query permission (BigQuery Job User) on the target datasets.

  • missing_connection_string. Neither project_id nor connection_string was supplied. Provide one of them in config.

  • BigQuery blocked by privacy policy. The deployment's egress policy disallows reaching bigquery.googleapis.com. An operator must allow that destination for customer connectors. See Troubleshooting.

Next steps

Last updated

Was this helpful?