> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prequel.co/llms.txt
> Use this file to discover all available pages before exploring further.

# BigQuery

> Steps to add a BigQuery data warehouse as a data source.

<Steps>
  <Step title="Create service account in BigQuery project">
    1. In the GCP console, in the same project as your BigQuery instance, navigate to the **IAM & Admin** menu.

    <Frame>
      ![](https://storage.googleapis.com/prequel_docs/images/gcp-iam-admin-full.png "iam & admin full.png")
    </Frame>

    2. Click into the **Service Accounts** tab.

    <Frame>
      ![](https://storage.googleapis.com/prequel_docs/images/gcp-iam-admin-full.png "service accounts full.png")
    </Frame>

    3. Click **Create service account** at the top of the menu.

    <Frame>
      ![](https://storage.googleapis.com/prequel_docs/images/gcp-create-service-account-menu.png "create service account menu.png")
    </Frame>

    4. In the first step, name the user and click **Create and Continue**.

    <Frame>
      ![](https://storage.googleapis.com/prequel_docs/images/gcp-service-account-name-options.png "service account name.png")
    </Frame>

    5. In the second step, grant the user the **BigQuery User** role.

    <Frame>
      ![](https://storage.googleapis.com/prequel_docs/images/gcp-bigquery-user.png)
    </Frame>

    6. In the third and final step, click **Done**.
    7. Back in the **Service accounts** menu, click the Actions dropdown next to the newly created service account and click **Manage keys**.

    <Frame>
      ![](https://storage.googleapis.com/prequel_docs/images/gcp-manage-service-account-keys.png "manage keys.png")
    </Frame>

    8. Click **Add key** and then **Create new key**.

    <Frame>
      ![](https://storage.googleapis.com/prequel_docs/images/gcp-create-new-key.png "create new key.png")
    </Frame>

    9. Select the **JSON** Key type and click **Create** and make note of the key that is generated.

    <Frame>
      ![](https://storage.googleapis.com/prequel_docs/images/gcp-create-json-key.png "json create.png")
    </Frame>
  </Step>

  <Step title="Create a staging bucket">
    Transferring data from BigQuery requires a temporary staging area within Google Cloud Storage to stage compressed data before copying to a destination.

    1. Log into the Google Cloud Console and navigate to **Cloud Storage**. Click **Create** to create a new bucket.

    <Frame>
      ![](https://storage.googleapis.com/prequel_docs/images/gcp-create-gcs-bucket.png)
    </Frame>

    2. Choose a **name** for the bucket. Click **Continue**. Select a **location** for the staging bucket. Make a note of both the **name** and the **location** (region).

    <Warning>
      **Choosing a `location` (region)**

      The location you choose for your staging bucket must match the location of your source dataset in BigQuery.
    </Warning>

    3. Click **continue** and complete the options that follow according to your preferences. Once the options have been filled out, click **Create**.
    4. On the **Bucket details** page that appears, click the **Permissions** tab, and then click **Add**.

    <Frame>
      ![](https://storage.googleapis.com/prequel_docs/images/gcp-add-permission-to-bucket.png)
    </Frame>

    5. In the **New principles** dropdown, add the Service Account created in **Step 1**, select the **Storage Admin** role, and click **Save**.

    <Frame>
      ![](https://storage.googleapis.com/prequel_docs/images/gcp-storage-admin.png)
    </Frame>
  </Step>

  <Step title="Grant permission on BigQuery source dataset">
    1. Navigate to your **BigQuery** project and click on the dataset you want to share. Make a note of the **Project ID** and **Data location**.
    2. In the menu on the right, click **Sharing** and then click **Permissions**.

    <Frame>
      ![](https://storage.googleapis.com/prequel_docs/images/bigquery-sharing-permissions.png)
    </Frame>

    3. Click **Add Principal**.

    <Frame>
      ![](https://storage.googleapis.com/prequel_docs/images/bigquery-add-principal.png)
    </Frame>

    4. Select the Service Account created in **Step 1**, then select the **BigQuery User** role and the **BigQuery Data Viewer** role. Click **Save**.

    <Frame>
      ![](https://storage.googleapis.com/prequel_docs/images/bigquery-user-data-viewer.png)
    </Frame>
  </Step>

  <Step title="Connect to Prequel">
    1. Use the **Project ID**, **Data Location**, **Source Dataset Name**, **Bucket Name**, **Bucket Region**, and **Service Account Private Key** (`.json` file) to [add the Source](/export/api-reference/overview) using the Prequel API.
  </Step>
</Steps>
