# BigQuery

## Before you start

To connect BigQuery to Select Star, you will need...

* Admin access to your BigQuery instance.

Complete all of the following steps to see BigQuery metadata, lineage, and popularity in Select Star.

1. [Create a service account for Select Star](#id-1.-create-a-service-account-for-select-star)
2. [Create a new JSON key](#id-2.-create-a-new-json-key)
3. [Connect BigQuery to Select Star](#id-3.-connect-bigquery-to-select-star)
4. [Choose databases and schemas](#id-4.-choose-databases-and-schemas)

## 1. Create a Service Account for Select Star

Go to <https://console.cloud.google.com/iam-admin/serviceaccounts>.

Click **+ Create Service Account**.

![](https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-949bb32ae9403885c74f4fb2fb345e427cf2cadb%2F2.png?alt=media\&token=dd41edb2-4576-4ae3-b9cd-527e10742a6d)

Grant the following roles to the service account:

* BigQuery Job User
* BigQuery Metadata Viewer
* BigQuery Resource Viewer
* BigQuery Data Viewer (optional: when this is turned off we won’t be able to show the detailed table information including table size, row count, etc)

![](https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-f453cf4e2e6fe6c5bdf683067a8e43337eca2e5c%2F3.png?alt=media\&token=9d9650a0-9bdb-4d2f-81ac-6e07985b1614)

Grant the <selectstar@getselectstar.com> user the Service account admin role.

![](https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-d4dd133a2cdcff0b34be80417cf6f5e089da2516%2F4.png?alt=media\&token=9b3598a7-998c-495b-83d9-2a97c9ebfcfc)

Click **Done**.

### Adding more projects

In order to add more projects in your Data Source you will need to have already created service account for one of the projects and:

1. Select your first project in which you have created the service account ![](https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-f5e30a5a84f1c36cecfd8d203af8def80d3f377e%2FBQ-dest-project.png?alt=media\&token=b5048830-5a4e-4746-920a-21115872d964)
2. Navigate to **IAM & Admin → Service accounts** in the project you have created the service account in and copy the email.

   <img src="https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-4255f0455884c9357a3c1738bf1589feacc77ca3%2Fservice-account-menu.png?alt=media&#x26;token=0885e930-8815-426f-929a-45edbaa9b042" alt="" data-size="original">

   **Copy the email** and save it for later.

   <img src="https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-b1f9119454994af6eeef2ddb33630fa36e1191f2%2FBQ-copy-email.png?alt=media&#x26;token=fd0bebc7-9cc3-4274-9f71-286e6a25e322" alt="" data-size="original">
3. Go to the **destination project**, i.e. the one that we want to grant the service account

   <img src="https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-c32a9167acb22c680a6c1cdb2b7f227294054a4b%2FBQ-second-proj.png?alt=media&#x26;token=b085e1c1-89ee-4bac-a263-6b8864b4733a" alt="" data-size="original">
4. In **IAM & Admin → IAM** and click on **“ADD”** at the top.

   a. Select IAM in menu and follow the link.

   <img src="https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-6361813f9edfee7f083da591cbea2519047b17a2%2FBQ-iam-admin-menu.png?alt=media&#x26;token=51a2e40b-346d-45bd-9be0-21b31486873a" alt="" data-size="original">

   b. Once in IAM, click "ADD"

   <img src="https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-b45cc5bcd2bad952b9957ba5c020d69f2735b73d%2FBQ-iam-admin-add.png?alt=media&#x26;token=db00f0b1-313d-43c5-933c-b27766242bdd" alt="" data-size="original">
5. Use the email of service account from step 2 (that you copied) and grant the roles from [step 1](#2.-create-a-service-account-for-select-star)

   <img src="https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-27488e1df38bafbed9a410684f73be3f129de1e1%2FBQ-allow-email.png?alt=media&#x26;token=4bf98c89-dd23-4bc3-b58f-480121cb8b96" alt="" data-size="original">
6. You have successfully granted your service account permissions in another project, continue those steps if you want to add more projects.

## 2. Create a new JSON Key

Once the Service Account is created, click the Select Star Service Account in the list.

Go to **Keys** tab, and click **Add Key** → **Create new key.**

![](https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-a06c5d5f8f4b111bb01c2a235674fd92da96bd58%2F5.png?alt=media\&token=d11bc995-14c2-4910-9524-b15775bdba50)

Leave the **Key type** as `JSON`, and click **Create**. It will begin downloading the JSON file.

Save this JSON file to easily complete [step 3](#4.-connect-bigquery-to-select-star).

## 3. Connect BigQuery to Select Star

Go to the Select Star **Settings**. Click **Data** in the sidebar, then **+ Add** to create a new Data Source.

![](https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-1b5ef3716637dedbfa0eb69326a83270b0773b0b%2FAdd_Data_Source_Settings.gif?alt=media)

Choose **BigQuery** in the Source Type dropdown and provide the following information:

![](https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-8a73f5004f67af0ea3bf9b5b60fb109e2e6c6569%2FScreen%20Shot%202021-11-12%20at%2010.29.27%20AM.png?alt=media\&token=47a3c32b-1e37-4daa-83de-bdd212fd6353)

* **Display Name:** This value is `BigQuery` by default, but you can override it if desired.
* **Service Account:** The JSON file created in [step 2](#3.-create-a-new-json-key) above. The JSON file will automatically populate all other fields in the modal.

## 4. Choose databases and schemas

After you fill in the information, you'll be asked to select the databases you'd like to load into Select Star.

{% hint style="info" %}
Select Star will not read queries or metadata or generate lineage for databases, schemas, or tables that are not loaded. Please load all data for which you expect to see lineage.

You can [change the databases and schemas](https://docs.selectstar.com/data-source-management/manage-data-sources#configure-a-data-source) you have loaded if needed.
{% endhint %}

Select the database and click **Next**.

![](https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-f07bd33bff68332d37142644059ff9514f561a80%2FScreen%20Shot%202021-11-12%20at%2010.29.58%20AM.png?alt=media\&token=c3eb65a8-914f-461f-b139-e7ee6e90dcb2)

For each database you selected, you'll be able to select the schemas.

![](https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-1d97e22cac174fcb78310ccf61b770019f6cd677%2FScreen%20Shot%202021-11-12%20at%2010.30.18%20AM.png?alt=media\&token=0cee5023-b325-4e90-a309-cda2f769b21e)

Your metadata should start loading automatically. Please allow 24-48 hours to completely generate popularity and lineage.

When the sync is complete, you'll be able to explore your BigQuery instance in Select Star. See the link below for more information on BigQuery in Select Star.

{% content-ref url="../learning-data/getting-started-bigquery" %}
[getting-started-bigquery](https://docs.selectstar.com/learning-data/getting-started-bigquery)
{% endcontent-ref %}

{% content-ref url="bigquery/bigquery-description-sync" %}
[bigquery-description-sync](https://docs.selectstar.com/integrations/bigquery/bigquery-description-sync)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.selectstar.com/integrations/bigquery.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
