Skip to content
Learn › Get data in › Connectors: open the docs menu

Connect Google BigQuery to Mammoth with a service account

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, 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 for the shared steps.

Google BigQuery New Connection dialog with the Upload service account file button BigQuery New Connection dialog with a service account JSON file attached and the Connect button enabled

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

BigQuery puts table names in backticks:

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 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 refreshWhat it does
Replace all rowsMatches the source after every refresh
Add only new rowsKeeps what you have and adds rows above the last value of a Key column
Add every row againShown instead when the result has no numeric or date column, so each refresh adds a full copy
Keep only the newest rowsEmpties 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

Refresh BigQuery data on a schedule

Choosing Daily at 06:00 creates a Dataset Refresh 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

Troubleshoot BigQuery permission errors

SymptomLikely causeFix
Permission deniedThe service account is missing a roleGive it both BigQuery Data Viewer and BigQuery Job User
Permission denied on one datasetYou want table-level access, not project-levelGrant the roles on the BigQuery dataset in BigQuery, then the dataset, then Sharing → Permissions
Project not visibleThe service account belongs to another projectUse a service account in the same Google Cloud project, or grant it access across projects through IAM
Was this page helpful?

Something wrong? support@mammoth.io