# Google BigQuery

## Set up a BigQuery warehouse

If you already have a BigQuery warehouse set up, you can skip this step.

* Visit <https://console.cloud.google.com>
* In the search bar, look for BigQuery
* Go through one of the guides to "Add your own data".
* You can test that things work by querying the resulting dataset table.

<figure><img src="https://4179539225-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MZqboFGZzD87nn7oPsm%2Fuploads%2FikSeELaT4MmpuFHmgydo%2FScreenshot%202023-09-07%20at%2012.09.53.png?alt=media&#x26;token=c20411fc-bcc9-435d-801e-65362785a76f" alt=""><figcaption></figcaption></figure>

#### Configure a Google Service Account

A Google service account is a special kind of account that can be used by programs to access Google resources like a BigQuery data warehouse. You will use this service account to connect DataCamp DataLab to your BigQuery warehouse.

To set up a new Google Service Account, please refer to [this excellent guide](https://docs.openbridge.com/en/articles/1856793-how-to-set-up-google-bigquery-creating-and-configuring-service-accounts-in-google-cloud-console). At the end of it, you'll have the JSON credentials file that you can use to set up the BigQuery connection in DataLab.

## Set up a Google BigQuery connection

When inside a workbook, click **View** > **Databases**, then click the **+** icon and follow the on-screen instructions. Upload the Service Account JSON and hit "Connect".

<figure><img src="https://4179539225-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MZqboFGZzD87nn7oPsm%2Fuploads%2FvPhZPabEMDDIKGEYusXa%2FScreenshot%202023-06-30%20at%2014.00.36.png?alt=media&#x26;token=1dc8ef57-132b-4b7e-bbe6-867f815c5452" alt=""><figcaption><p>Create a BigQuery connection</p></figcaption></figure>

For detailed instructions, see [connect-your-data-to-workspace](https://datalab-docs.datacamp.com/connect-to-data/connect-your-data-to-workspace "mention").

## Query the database

You can now query the BigQuery data warehouse with a [sql-cell](https://datalab-docs.datacamp.com/work/sql-cell "mention"). Select it in the **Select source** dropdown in the top left corner of a SQL cell, or select the sample BigQuery data warehouse.

<figure><img src="https://4179539225-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MZqboFGZzD87nn7oPsm%2Fuploads%2FO7KaPelnOrGiGFLeDFvg%2Fimage.png?alt=media&#x26;token=6448a3ec-095f-4c98-8c46-565d5ea01e4c" alt=""><figcaption><p>Example of a SQL cell using the <code>BigQuery Integration</code> connection. The query result is available as <code>df</code>.</p></figcaption></figure>
