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

# BigQuery Setup and Configuration

> Set up BigQuery as an Inflection data source and export destination.

## Export Inflection Data to BigQuery

For information on tables and schemas that inflection exports to BigQuery, please read this

<AccordionGroup>
  <Accordion title="Set up Export to BigQuery in Inflection">
    These steps need to be run by someone with access to

    1. Go to **Connections → Data Connections**, then click **Add new connection**.

           <img src="https://mintcdn.com/inflection-4b2c0de4/N4VRWuxaoalXbMy_/images/connections/warehouses/bigquery/01.png?fit=max&auto=format&n=N4VRWuxaoalXbMy_&q=85&s=15366e11bf3282cc36a66b41c0a70046" alt="Add new connection button on the Data Connections page" width="3840" height="1868" data-path="images/connections/warehouses/bigquery/01.png" />

    2. **Choose your platform**: Select **BigQuery** as your destination platform.

    3. **Select connection type**: Choose **Export Data to BigQuery**.

           <img src="https://mintcdn.com/inflection-4b2c0de4/N4VRWuxaoalXbMy_/images/connections/warehouses/bigquery/02.png?fit=max&auto=format&n=N4VRWuxaoalXbMy_&q=85&s=bdfc90a7aa5af7b6d42bb5d1b88d4892" alt="Choosing BigQuery as the platform and Export Data to BigQuery as the connection type" width="1024" height="948" data-path="images/connections/warehouses/bigquery/02.png" />

    4. **Enter your BigQuery credentials**
       * Connection name - A human friendly name for this **BigQuery** connection
       * Google Project Id - Project id of the GCP
       * Dataset - Name of the dataset where inflection should write data

    5. Click **Create Connection** to set up the connection. Note that syncing will NOT BEGIN and connection will be in INACTIVE state until the credentials and destination tables are created Inflection.
  </Accordion>

  <Accordion title="Set up BigQuery to accept Inflection Data">
    ### Verifying access to sync data

    Inflection requires specific permissions to sync data.

    * On your Google Cloud console, ensure that you've selected the project containing your BigQuery Instance.
    * From the navigation menu, go to IAM & Admin Panel. Click on "Grant Access".
    * Then, add the following service account as principle and add the specified role.
    * This will help us read the data and sync the data to inflection.

    **Principal:** [inflection-datawarehouse-write@silken-fortress-380708.iam.gserviceaccount.com](mailto:inflection-datawarehouse-write@silken-fortress-380708.iam.gserviceaccount.com)

    **Roles:**

    ```json theme={null}
    bigquery.jobs.create, bigquery.tables.create, bigquery.tables.delete, 
    bigquery.tables.get, bigquery.tables.getData, bigquery.tables.update, 
    bigquery.tables.updateData
    ```
  </Accordion>

  <Accordion title="Submit Setup for Activation">
    Once your credentials are saved and your data team gave above accesses, your setup is complete.

    At this point:

    * Inflection's team will validate the setup and activate the sync for you.
    * No additional steps are required from your side.
      * Optionally, you may test or delete the connection at this stage
    * You will be notified once the sync has started and data is being sent.

    <Info>
      Activation may take up to two business days.
    </Info>
  </Accordion>
</AccordionGroup>

<img src="https://mintcdn.com/inflection-4b2c0de4/N4VRWuxaoalXbMy_/images/connections/warehouses/bigquery/03.png?fit=max&auto=format&n=N4VRWuxaoalXbMy_&q=85&s=a193ea93ea3764509dd519b11c07b9b6" alt="Export to BigQuery connection created and pending activation" width="2880" height="1624" data-path="images/connections/warehouses/bigquery/03.png" />

And that's it! Once you are set up, you can monitor sync health by following our guide here

## Import Product Activity from BigQuery to Inflection

For information on generic import guidelines, please read this.

<AccordionGroup>
  <Accordion title="Set up Inflection to read from BigQuery">
    1. In the Inflection UI, select Connections on the left sidebar > "Data Connections" > "Add new Connection"

           <img src="https://mintcdn.com/inflection-4b2c0de4/N4VRWuxaoalXbMy_/images/connections/warehouses/bigquery/04.png?fit=max&auto=format&n=N4VRWuxaoalXbMy_&q=85&s=24474b87156326c948b65a7cd0fcdf75" alt="Add new Connection option under Data Connections in the Inflection UI" width="710" height="648" data-path="images/connections/warehouses/bigquery/04.png" />

    2. Copy the dataset name and select Continue to add required permissions.

           <img src="https://mintcdn.com/inflection-4b2c0de4/N4VRWuxaoalXbMy_/images/connections/warehouses/bigquery/05.png?fit=max&auto=format&n=N4VRWuxaoalXbMy_&q=85&s=2742697a618c940a06a82fa310080f05" alt="Dataset name shown with Continue button to add required permissions" width="464" height="354" data-path="images/connections/warehouses/bigquery/05.png" />

    3. Name your connection in the Connection name field, add your Project id, and save the connection:

           <img src="https://mintcdn.com/inflection-4b2c0de4/N4VRWuxaoalXbMy_/images/connections/warehouses/bigquery/06.png?fit=max&auto=format&n=N4VRWuxaoalXbMy_&q=85&s=0f38a47add85f60cabbbc5b15f080da3" alt="Connection name and Project id fields for the BigQuery connection" width="462" height="390" data-path="images/connections/warehouses/bigquery/06.png" />
  </Accordion>

  <Accordion title="Set up BigQuery to allow Inflection reads">
    The below permission needs to be given to our service account by the customers on their project:

    1. `bigquery.dataViewer`: For us to read the data. Cloud console command:

    ```shell theme={null}
    gcloud projects add-iam-policy-binding <project_id> --member serviceAccount:<inflection_service_account_email> --role roles/bigquery.dataViewer
    ```

    2. `biguquery.user`: For us to read the dataset's metadata and list tables in the dataset, and also to run export job. Cloud console command:

    ```shell theme={null}
    gcloud projects add-iam-policy-binding <project_id> --member serviceAccount:<inflection_service_account_email> --role roles/bigquery.user
    ```

    3. `bigquery.dataEditor`: This role has to be provided to the service account on the dataset `inflection`. This is for us to calculate diffs within the dataset `inflection`. Cloud console command:

    ```shell theme={null}
    bq query --nouse_legacy_sql 'GRANT `roles/bigquery.dataEditor` ON SCHEMA inflection TO "serviceAccount:<inflection_service_account_email>"'
    ```
  </Accordion>
</AccordionGroup>
