> AI agents: this is one page from Mammoth Analytics documentation. The index of all pages as Markdown is https://mammoth.io/docs/llms.txt. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get Markdown.

# Connect Google BigQuery to Mammoth with a service account

> Connect Mammoth to Google BigQuery with a service account JSON key, grant the right roles, and import a table or SQL query as a refreshing dataset.

The Google BigQuery connector imports a table, or the result of your own SQL query, from BigQuery into Mammoth as a dataset. It signs in with a Google Cloud service account key file, so there is no OAuth sign-in. Open it from **Data Library** > **New dataset** > **Connectors**, search for **BigQuery** and click **Google BigQuery**. Project Admins create the connection; Project Editors can start datasets from a connection the project already has.

## What you can bring in from BigQuery

- Any table the service account can read. BigQuery groups tables into **datasets**, which work like schemas, and the **Tables** list groups tables under their BigQuery dataset.
- The result of your own `SELECT` query.

The Mammoth dataset can refresh daily or only when you ask.

## Before you connect BigQuery

You need:

- A Google Cloud project with BigQuery turned on.
- A service account with the **BigQuery Data Viewer** role (or equivalent) and the **BigQuery Job User** role.
- The service account's JSON key file, downloaded to your computer.

### Create a BigQuery service account and key

1. In the [Google Cloud Console](https://console.cloud.google.com), go to **IAM & Admin → Service Accounts**.
2. Click **Create Service Account**.
3. Give it a name, for example `mammoth-bigquery`.
4. Grant the roles **BigQuery Data Viewer** (read access) and **BigQuery Job User** (to run queries).
5. Click **Done**.
6. Open the service account, go to **Keys**, click **Add Key → Create new key**, and select **JSON**.
7. Save the downloaded JSON file. You upload it to Mammoth in the next step.

The key file grants access to your BigQuery project. Store it securely and don't share it. To revoke access, delete the key in Google Cloud Console under **IAM & Admin → Service Accounts**, then your account, then **Keys**.

## Connect Google BigQuery to Mammoth

1. Go to the **Data Library**, click **New dataset**, and choose **Connectors**.
2. Search for **BigQuery** and click the **Google BigQuery** tile. The connection form opens.
3. Click **Upload service account file** and select the JSON key file.
4. Click **Connect**. Once Mammoth has connected, the connector workspace opens on your tables.

If you already have a BigQuery connection, pick it under **Your connections** in the launcher instead. See [Connect a database or app](https://mammoth.io/docs/learn/get-data-in/connect-a-source/) for the shared steps.

![Google BigQuery New Connection dialog with the Upload service account file button](https://mammoth.io/docs/images/20260615_094036_Bigquery_screen_11.webp)

![BigQuery New Connection dialog with a service account JSON file attached and the Connect button enabled](https://mammoth.io/docs/images/20260615_094058_Bigquery_screen_2_uploaded_json.png1.webp)

## Query a BigQuery table in the SQL view

1. In **Tables**, click a table. Mammoth opens its rows with the `SELECT *` query that read them, shown above the rows.
2. To change the query, click **Edit SQL**, edit it, and click **Run**.

![BigQuery Existing Connections list showing the service account and its project - dataset profiles](https://mammoth.io/docs/images/20260615_094122_Bigquery_screen_3_profiles1.webp)


BigQuery puts table names in backticks:

```sql
SELECT order_id, customer_id, amount, created_at
FROM `my-project.analytics.orders`
WHERE DATE(created_at) >= DATE_SUB(CURRENT_DATE(), INTERVAL 90 DAY)
  AND status = 'completed'
```

[Connect a database or app](https://mammoth.io/docs/learn/get-data-in/connect-a-source/) covers the full SQL view.

## Save BigQuery data as a dataset

1. Click **Save as dataset**.
2. Enter a **Name** and pick a folder.
3. Under **Keep it up to date**, choose **Daily at 06:00** or **Only when I ask**.
4. Next to the sentence that says what each refresh does, click **Change** and pick an option under **On each refresh** (see the table below).
5. Click **Save as dataset**.

| On each refresh | What it does |
| --- | --- |
| **Replace all rows** | Matches the source after every refresh |
| **Add only new rows** | Keeps what you have and adds rows above the last value of a **Key column** |
| **Add every row again** | Shown instead when the result has no numeric or date column, so each refresh adds a full copy |
| **Keep only the newest rows** | Empties the dataset, then brings in rows since the last refresh (needs a **Key column**) |

A key column is a column whose values only ever go up, such as an ID or a date.

![Save as a dataset dialog with Name, Save in, the row estimate, Keep it up to date (Daily at 06:00 or Only when I ask) and what each refresh does](https://mammoth.io/docs/images/20261102_save-as-dataset-dialog.webp)

## Refresh BigQuery data on a schedule

Choosing **Daily at 06:00** creates a [Dataset Refresh](https://mammoth.io/docs/learn/automate/refresh-a-dataset/) automation that you can reschedule later.

After the dataset is saved, you can change what a refresh does in its **Update method**: **Replace all data**, **Add new rows only** or **Keep only the newest rows**.

![Hokulani_Data dataset details showing its BigQuery query and a Google BigQuery batch with state Active](https://mammoth.io/docs/images/20260615_094213_Screenshot2026-05-211231511.webp)

## Troubleshoot BigQuery permission errors

| Symptom | Likely cause | Fix |
| --- | --- | --- |
| Permission denied | The service account is missing a role | Give it both **BigQuery Data Viewer** and **BigQuery Job User** |
| Permission denied on one dataset | You want table-level access, not project-level | Grant the roles on the BigQuery dataset in **BigQuery**, then the dataset, then **Sharing → Permissions** |
| Project not visible | The service account belongs to another project | Use a service account in the same Google Cloud project, or grant it access across projects through IAM |

## Related

- [Connect a database or app](https://mammoth.io/docs/learn/get-data-in/connect-a-source/): the shared connector workspace steps and the full SQL view.
- [Manage saved connections](https://mammoth.io/docs/learn/get-data-in/connections/): edit, reuse or delete this connection.
- [Refresh a dataset](https://mammoth.io/docs/learn/automate/refresh-a-dataset/): change when the dataset refreshes.
- [Google Cloud Storage](https://mammoth.io/docs/learn/get-data-in/connectors/google-cloud-storage/): import files from a bucket with a service account.
- [Connector reference](https://mammoth.io/docs/learn/get-data-in/connectors/): every source Mammoth connects to.

---
Source: https://mammoth.io/docs/learn/get-data-in/connectors/bigquery.md · Updated: 2026-11-08
