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

# BigQuery

> Create a service account and grant Pavo read access to your BigQuery data.

### 1. BigQuery Access Setup

#### Step 1: Create a New Service Account in the GCP project you want Pavo to access

For example: `<sa_name>@<project>.iam.gserviceaccount.com`

#### Step 2: Grant BigQuery Permissions

In case of BQ data in multiple projects, grant the created SA access across all the projects.

* In the Google Cloud Console, switch to the project that contains the BigQuery data you want us to read.
* In the left navigation bar, go to **IAM & Admin → IAM**.
* Click **Grant access**
* In **New principals**, enter: name of the created sa `<sa_name>@<project>.iam.gserviceaccount.com`
* In **Role**, add the following roles (you may need to add multiple):

**BigQuery Metadata Viewer**<br />*Category:* BigQuery → BigQuery Metadata Viewer<br />*Role ID:* roles/bigquery.metadataViewer

If you prefer CLI:

```bash theme={null}
gcloud projects add-iam-policy-binding <CUSTOMER_PROJECT_ID> \
--member="serviceAccount:<sa_name>@<project>.iam.gserviceaccount.com" \
--role="roles/bigquery.metadataViewer"
```

**BigQuery Job User**<br />*Category:* BigQuery → BigQuery Job User<br />*Role ID:* roles/bigquery.jobUser

If you prefer CLI:

```bash theme={null}
gcloud projects add-iam-policy-binding <CUSTOMER_PROJECT_ID> \
--member="serviceAccount:<sa_name>@<project>.iam.gserviceaccount.com" \
--role="roles/bigquery.jobUser"
```

**BigQuery Resource Viewer**<br />*Category:* BigQuery → BigQuery Resource Viewer<br />*Role ID:* roles/bigquery.resourceViewer<br />(This role includes the bigquery.jobs.listAll permission required to query INFORMATION\_SCHEMA.JOBS / JOBS\_BY\_PROJECT.)

If you prefer CLI:

```bash theme={null}
gcloud projects add-iam-policy-binding <CUSTOMER_PROJECT_ID> \
--member="serviceAccount:<sa_name>@<project>.iam.gserviceaccount.com" \
--role="roles/bigquery.resourceViewer"
```

* Click **Save**.

#### Step 3: Create Analysis Dataset \[IMPORTANT]

1. **Required**: Create a new BigQuery dataset by the name '**pavo\_dataset**' (Use this *specific name* for the dataset, this will be used for temporary tables during analysis)
2. **Required**: Grant the Pavo service account the *BigQuery Data Editor* role for this dataset
