Area: Ingestion
Sub-Area: Authentication
Applies to: OSS + Cloud
Issue
BigQuery ingestion fails with permission errors when it extracts metadata, reads usage and lineage, runs profiling queries, or reads Google Drive-backed external tables. This usually happens when the service account is missing permissions that the connector needs.
Example error messages. Google produces these, not DataHub, so the exact wording can vary:
Permission denied: bigquery.tables.getAccess Denied: BigQuery BigQuery: Permission denied while getting Drive credentialsUser does not have bigquery.jobs.create permission403 Forbidden: Access denied to resource
You Might Be Asking
- What permissions does the DataHub service account need for BigQuery?
- How do I grant permissions for cross-project BigQuery ingestion?
- Why can't DataHub access my BigQuery tables?
Cause
The connector needs more than roles/bigquery.metadataViewer. Each feature needs its own permissions:
| Need | Where | Permissions |
|---|---|---|
| Basic metadata ingestion | Extractor project (where the service account lives) |
bigquery.jobs.create, bigquery.jobs.list, bigquery.readsessions.create, bigquery.readsessions.getData
|
| Basic metadata ingestion | Every target project |
bigquery.datasets.get, bigquery.datasets.getIamPolicy, bigquery.tables.list, bigquery.tables.get, bigquery.routines.get, bigquery.routines.list, resourcemanager.projects.get, and resourcemanager.projects.list (only when you don't set project_ids). The DataHub docs map these to roles/bigquery.metadataViewer. |
| Lineage and usage | Each ingested project |
bigquery.jobs.listAll (roles/bigquery.resourceViewer) |
Legacy lineage and usage (use_queries_v2: false) from audit logs |
Each ingested project |
logging.logEntries.list and logging.privateLogEntries.list (roles/logging.privateLogViewer). Not required when use_exported_bigquery_audit_metadata is enabled. |
Profiling, or use_tables_list_query_v2
|
Every target project | bigquery.tables.getData |
use_queries_v2 defaults to true, so a default setup does not need the audit log permissions. use_tables_list_query_v2 defaults to false. DataHub turns it on automatically when profiling is enabled. When it is on and listing a dataset's tables fails, the failure "Unable to get tables for dataset" asks whether the service account has bigquery.tables.list, bigquery.routines.get, bigquery.routines.list and bigquery.tables.getData.
Solution
-
Grant the permissions in the table above. The DataHub docs recommend a custom role for the extractor project permissions. Grant the target project permissions with
roles/bigquery.metadataViewer:gcloud projects add-iam-policy-binding YOUR_PROJECT_ID \ --member="serviceAccount:datahub@PROJECT.iam.gserviceaccount.com" \ --role="roles/bigquery.metadataViewer"For lineage and usage, also grant
roles/bigquery.resourceVieweron each ingested project:gcloud projects add-iam-policy-binding YOUR_PROJECT_ID \ --member="serviceAccount:datahub@PROJECT.iam.gserviceaccount.com" \ --role="roles/bigquery.resourceViewer"If you profile, or enable
use_tables_list_query_v2, also grantbigquery.tables.getDataon every target project. See the full permission table. -
For cross-project ingestion, list the projects in
project_idsand grant the permissions on every one of them. When you setproject_ids, DataHub never appliesproject_id_patternand ignoresproject_id. Withuse_queries_v2(the default), lineage and usage come from each ingested project's own job history. If the jobs that write your tables run in another project, add that project toproject_idsand grant it the same roles.source: type: bigquery config: project_ids: ["project-1", "project-2", "project-3"] -
Fill in the whole
credentialblock.private_key_id,private_key,client_emailandclient_idhave no defaults, so each one is required. Leaving outclient_idmakes config validation fail.source: type: bigquery config: credential: project_id: "your-project" private_key_id: "key-id" private_key: "${GOOGLE_PRIVATE_KEY}" client_email: "datahub@project.iam.gserviceaccount.com" client_id: "123456789012345678901"Recipes resolve
${VAR}from environment variables, so setGOOGLE_PRIVATE_KEYwhere the ingestion runs. For UI ingestion, store the key as a DataHub secret and reference it with the same${NAME}syntax. See secrets and environment variables. DataHub converts escaped\nsequences inprivate_keyto real newlines, so you can paste the key as it appears in the service account JSON file.See Create a service account in the extractor project for the key file and a full credential example.
-
For the
Permission denied while getting Drive credentialserror, share the Google Drive document behind the external table with the service account. See profiling requirements. -
To limit which datasets are ingested, use
dataset_pattern. It matches against<project_id>.<dataset_name>.