Skip to content
HelpBigQuery

BigQuery

Connect an agent to BigQuery: the service account and roles it needs, what it does with your data, how query costs stay in check, and how to disconnect.

What it is

An agent connected to BigQuery answers questions from your data the way an analyst on your team would. It finds the right dataset and table, reads a table’s columns, writes the query and explains the answer in plain words. Its queries only read. When it should add or change rows, or create a table or a view, it asks you first, every time.

Before you start

The agent connects as a service account: a Google account made for software, in your own Google Cloud project. The roles you give it there decide what the agent can see and do, so you can share a whole project or just a few datasets. You need permission to create service accounts in the project (a project owner has it), and about five minutes.

  1. In Google Cloud, open IAM and admin, then Service accounts, and choose Create service account. Name it after the agent (for example “Maya AgentTeams”).
  2. Give it the roles BigQuery Job User, so it can run queries, and BigQuery Data Viewer, so it can read. Grant Data Viewer on the whole project, or leave it out here and grant it on just the datasets the agent should see (open the dataset in BigQuery, then Sharing). Add BigQuery Data Editor only if the agent should add or change rows.
  3. Open the new service account, go to Keys, choose Add key, Create new key and JSON. A key file downloads. Keep it private, like a password.

If Google says creating keys is turned off, your organization blocks service account keys. An admin of your Google Cloud organization can allow them for this project (the policy is called “Disable service account key creation”). The BigQuery API has to be on in the project; it is in new projects.

Connecting BigQuery

  1. Open the agent, go to the Tools tab and choose BigQuery.
  2. Paste the whole key file, or choose it.
  3. The wizard signs in with the key and shows what the agent can do: run queries, see the project’s datasets (with their names), and change data only with your approval. You’re done.

What the agent can do

  • Find datasets and tables, in your project and in other projects the service account may read
  • Read a table’s columns, size, partitioning and description before it writes a query
  • Answer questions with queries that only read, and fetch the rest of a long result
  • Say how much a query would scan before running it
  • Add rows, run an update, insert, delete or merge, and create tables or views, each approved first

It never deletes a dataset or a table, never runs scripts, exports or procedures, and never changes who has access: those are done in Google Cloud.

What queries cost

Queries run in the service account’s project and are billed there by Google, like any query you run yourself. With on-demand pricing that’s by the amount of data a query scans. Before every query the agent checks how much it would scan, and no query may scan more than 100 GB unless you approve a higher limit for it. The agent keeps scans small by reading only the columns it needs and filtering on the table’s date or partition column.

Every query the agent runs is labelled agentteams=employee and agentteams_employee=<its name>, so you can find its queries in BigQuery’s job history and in your billing reports.

Projects without billing

A Google Cloud project without a billing account uses BigQuery’s free sandbox. There the agent can read your tables and run queries as usual, but Google refuses every change to data and adding rows. The wizard says so when you connect such a project; once billing is on for the project in Google Cloud, changes work, without connecting again.

Disconnecting

  1. In AgentTeams. Open the agent’s Tools tab and disconnect BigQuery. The key is deleted from AgentTeams.
  2. In Google Cloud. Open the service account, go to Keys and delete the key, or delete the service account. The key is yours, so this is the step that ends its access at Google.

Disconnecting leaves your data as it is, and the agent keeps what it learned. Remove the agent entirely if you want that gone too.

If something is off

  • Google doesn’t accept the key. The key may have been deleted or disabled: make a new one for the service account and paste the whole file.
  • The agent can’t run queries. Give the service account the BigQuery Job User role on its own project.
  • It can’t see a dataset. Give the service account BigQuery Data Viewer on that dataset, or on its project.
  • A query stopped at the scan limit. Ask the agent to narrow it (fewer columns, a shorter date range), or approve a higher limit when it asks.
  • It can read but can’t change data. The project has no billing account (BigQuery’s free sandbox). Turn on billing for it in Google Cloud.
  • A query can’t combine two tables. One query reads and writes in a single location, so a table in the US can’t be copied into a dataset in the EU, for example. Keep the tables a query uses in one location.

Still stuck? Email support@agentteams.com and a human will write back.