Area: Ingestion
Sub-Area: BigQuery
Applies to: OSS + Cloud
Issue
BigQuery ingestion extracts datasets from projects or datasets you didn't intend, or your project and dataset filters don't limit what DataHub ingests.
You Might Be Asking
- Why does my
project_id_patterndeny list not exclude projects? - How do I ingest only some datasets in a project?
- Which projects does lineage and usage come from?
- Which permissions does the service account need?
Cause
-
project_idsoverridesproject_id_pattern. When you setproject_ids, DataHub takes those projects as given and never checksproject_id_pattern. Its allow and deny rules do nothing. -
project_idis ignored next toproject_ids. If you set both, DataHub logs "Please useproject_idsconfig. Configproject_idwill be ignored." On its own,project_idbecomesproject_ids: [project_id]. -
Without
project_ids, DataHub lists every project the service account can see. It then filters them withproject_id_pattern. The default allows all projects. -
project_labelshas no effect whenproject_idsorproject_idis set. -
Project filters can't exclude single datasets. Dataset filtering uses
dataset_pattern.
Solution
-
Choose one way to select projects.
Option A: list the exact projects.
source: type: bigquery config: project_ids: - "analytics-prod" - "data-warehouse"Option B: filter by pattern. Don't set
project_idsorproject_id.source: type: bigquery config: project_id_pattern: allow: ["prod-.*", "analytics-.*"] deny: ["test-.*", "dev-.*", ".*-sandbox"]You can also filter by label with
project_labels(formatkey:value). DataHub filters by label first, then byproject_id_pattern. -
Filter datasets with
dataset_pattern. DataHub matches it against<project_id>.<dataset_name>. A pattern with no dot, such asanalytics, matches that dataset name in any project.source: type: bigquery config: project_ids: - "analytics-prod" dataset_pattern: allow: ["analytics-prod\\.reporting.*"] deny: [".*\\.tmp_.*"]schema_patternis a deprecated alias that DataHub uses only whendataset_patternis unset. -
Check where lineage and usage come from.
include_table_lineagedefaults to true. With the defaultuse_queries_v2, lineage and usage come from the job history of each project you ingest. If the jobs that write your tables run in another project, add that project to the ingested projects and grant it the same roles. -
Check the service account permissions. A service account that sees many projects is the reason pattern-only setups pull in extra projects. Grant only what is needed:
- On the extractor project (where the service account lives):
bigquery.jobs.create,bigquery.jobs.list,bigquery.readsessions.create,bigquery.readsessions.getData. - On every target project: the permissions in
roles/bigquery.metadataViewer.resourcemanager.projects.listis needed only when you don't setproject_ids. - For lineage and usage,
bigquery.jobs.listAll(roles/bigquery.resourceViewer) on each ingested project. -
bigquery.tables.getDataonly if you enable profiling oruse_tables_list_query_v2.
The BigQuery Data Viewer role alone doesn't match these requirements.
- On the extractor project (where the service account lives):
-
If a run finds no projects, the report shows a "metadata-extraction" failure that says
resourcemanager.projects.listmay be missing. Grant the service accountroles/bigquery.metadataViewer, or setproject_idsto skip the project list call. -
Test with one project first. Set a single entry in
project_ids, confirm only the intended datasets appear in DataHub, then add more projects.