Repository navigation
Fixes 38703: Make dbt BigQuery wildcard sources upstream of every table they read - #38704
Merged
Merged
Conversation
A dbt source whose identifier ends in * (events_*) is a BigQuery wildcard table. Upstream parsing looked it up as one literal table, found nothing and dropped it, so models reading GA4-style sources lost that lineage. For services whose resolver supports wildcard tables (BigQuery), the data model now keeps the wildcard FQN as an upstream, and create_dbt_lineage expands it into one edge per match. The expansion searches where every other dbt node is looked up (catalogMapping database, then the manifest database, across services when searchAcrossDatabases is set) and runs once per run. An unmatched wildcard is reported and gets no edge instead of a single-table lookup. An incomplete match (over the candidate limit, date-constrained, or spread over several services) is reported, and both lineage stages of that model add their edges without overriding. Tests and exposures still need one table, and other engines keep the identifier literal. Records the rule as v3 of ADR:2026-11-03-bigquery-daily-shards-use-stable-logical-tables.
ulixius9
requested review from
mohittilala
and
a balanced review from Copilot
November 25, 2026 14:21
Contributor
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
11 tasks done
…-ingestion-log-analysis
Code Review ✅ Approved 🟡 Medium riskExpanding BigQuery dbt wildcard sources changes lineage metadata; incomplete matches disable overrides, so stale upstream edges may remain alongside new parents. Makes dbt BigQuery wildcard sources such as GA4 VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
harshsoni2024
approved these changes
Nov 26, 2026
11 tasks done
ulixius9
added a commit
that referenced
this pull request
Nov 27, 2026
…le they read (#38704) (#38875) * Make dbt BigQuery wildcard sources upstream of every table they read A dbt source whose identifier ends in * (events_*) is a BigQuery wildcard table. Upstream parsing looked it up as one literal table, found nothing and dropped it, so models reading GA4-style sources lost that lineage. For services whose resolver supports wildcard tables (BigQuery), the data model now keeps the wildcard FQN as an upstream, and create_dbt_lineage expands it into one edge per match. The expansion searches where every other dbt node is looked up (catalogMapping database, then the manifest database, across services when searchAcrossDatabases is set) and runs once per run. An unmatched wildcard is reported and gets no edge instead of a single-table lookup. An incomplete match (over the candidate limit, date-constrained, or spread over several services) is reported, and both lineage stages of that model add their edges without overriding. Tests and exposures still need one table, and other engines keep the identifier literal. Records the rule as v3 of ADR:2026-11-03-bigquery-daily-shards-use-stable-logical-tables. * Fix basedpyright errors in dbt wildcard source lineage (cherry picked from commit bee5926)
ulixius9
added a commit
that referenced
this pull request
Nov 27, 2026
…ry table they read (backport 2.0 #38704) (#38707) * Make dbt BigQuery wildcard sources upstream of every table they read A dbt source whose identifier ends in * (events_*) is a BigQuery wildcard table. Upstream parsing looked it up as one literal table, found nothing and dropped it, so models reading GA4-style sources lost that lineage. For services whose resolver supports wildcard tables (BigQuery), the data model now keeps the wildcard FQN as an upstream, and create_dbt_lineage expands it into one edge per match. The expansion searches where every other dbt node is looked up (catalogMapping database, then the manifest database, across services when searchAcrossDatabases is set) and runs once per run. An unmatched wildcard is reported and gets no edge instead of a single-table lookup. An incomplete match (over the candidate limit, date-constrained, or spread over several services) is reported, and both lineage stages of that model add their edges without overriding. Tests and exposures still need one table, and other engines keep the identifier literal. Records the rule as v3 of ADR:2026-11-03-bigquery-daily-shards-use-stable-logical-tables. * Fix basedpyright errors in dbt wildcard source lineage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes:
Fixes #38703
Backport to
2.0: #38707.A dbt source whose
identifieris a BigQuery wildcard table, such as GA4'sevents_*, never produced dbt lineage. dbt looks up source identifiers literally (#35683), so*was escaped and the lookup asked for a table named exactlyevents_*. Nothing matched, so the parent was dropped from every model that reads it, even withshardedTablescataloging the shards asevents_yyyymmdd/events_intraday_yyyymmdd.create_dbt_lineagealready had a wildcard fan-out (#36867), but no dbt source ever reached it.This change fixes that. For a service whose table resolver declares wildcard-table support (only BigQuery does):
create_dbt_lineageturns it into one edge per table BigQuery would read, including both the daily and intraday families.catalogMappingdatabase in the configured service, then in any service, then the manifest database, then any service whensearchAcrossDatabasesis set.events_2026*), or spread over several services is reported. Both lineage stages of that model (dbt dependencies and SQL) then add edges without overriding, so the wildcard's earlier edges survive and new parents still link.*identifier there still resolves to its table.The rule is recorded as v3 of ADR:2026-11-03-bigquery-daily-shards-use-stable-logical-tables.
Type of change:
High-level design:
TableBindingResolution.supports_wildcard_tables: a class attribute,Falseby default andTrueonBigQueryTableBindingResolution. This keeps BigQuery knowledge out of the dbt source; dbt only asks the configured service's resolver.DbtSource.parse_upstream_nodes_with_names(..., expand_wildcard_sources=False): onlyyield_data_modelspassesTrue. The test, freshness and exposure callers keep the default. The flag is passed through ephemeral models.create_dbt_lineage/create_dbt_query_lineage: read the wildcard's outcome from a bounded per-run LRU (wildcard_expansions), cleared inyield_data_models. An outcome is the matched tables, orNonewhen the match was incomplete._overrides_lineagederives one override decision from it for both stages. This matters because the sink's delete-by-source runs on the first override request for a target, so a single stage still overriding would delete the edges the other one preserved.events_\*to just theevents_family inside the BigQuery resolver. BigQuery'sevents_*also readsevents_intraday_*and anyevents_…table, so linking one family would be a guess.overrideLineage, the model's other edges would then delete the wildcard's earlier edges.Tests:
Use cases covered
events_*gets an edge from both theevents_andevents_intraday_shard families, and the edges carry the model SQL.events_2026*), with and withoutoverrideLineage: the model's other parent (orders) still links, and neither lineage stage overrides.catalogMapping: the mapped database is found in the configured service and in another service, and the lookup falls back to the manifest database.searchAcrossDatabases: the wildcard is found in another service. Matches in two services are reported and link nothing.*identifiers: no upstream, and the literal table still gets its lineage edge.Unit tests
ingestion/tests/unit/entity_resolution/test_resolver.py(test_dbt_wildcard_source_*,test_dbt_incomplete_wildcard_source_*,test_dbt_complete_wildcard_source_*), andingestion/tests/unit/test_dbt.py(TestDbtSourceIdentifiers: the newyield_data_modelswiring test, plus a lineage assertion added to the literal-identifier test).yield_data_modelsflag, the ephemeral pass-through, the override decision in each stage, the cache and its reset, thecatalogMappingand cross-service lookups, the several-services check, the unmatched-wildcard handling, and the literal-*exclusion).main:pytest tests/unit/entity_resolution/ tests/unit/test_dbt.py tests/unit/test_dbt_ingest.py tests/unit/test_dbt_test_definition.py tests/unit/test_dbt_test_descriptions.py tests/unit/test_dbt_python_models.py tests/unit/test_dbt_config_errors.py tests/unit/test_dbt_http_config.py tests/unit/topology/database/test_bigquery.py tests/unit/topology/database/test_bigquery_sharding.py→ 687 passed, 0 failed. After the rebase, the wildcard, identifier and lineage selection gave 167 passed.
Backend integration tests
Ingestion integration tests
create_dbt_lineageagainst a wildcard source. The merge queue runstests/integration/.Playwright (UI) tests
Manual testing performed
shardedTableson). Every GA4events_*/users_*source and the audit-log wildcard sources loggedUnable to find the table '…events_*', and the models reading them had no dbt lineage from those tables. Date-suffixed sources in the same run resolved to their…_yyyymmddfamilies, so sharding itself worked.UI screen recording:
Not applicable: ingestion-only bug fix.
Checklist:
I have read the CONTRIBUTING document.
My PR title is
Fixes <issue-number>: <short explanation>My PR is linked to a GitHub issue via
Fixes #<issue-number>above.I have commented on my code, particularly in hard-to-understand areas.
For JSON Schema changes: N/A, no schema change.
For a UI feature or feature task: N/A.
I have added tests (unit / integration / Playwright as applicable) and listed them above.
Self-review: I reviewed the final diff against
REVIEW.md(thepr-checklistskill runs it) and fixed every 🔴 finding, or answered it on the line below.06405454(content-identical to this head after the rebase). Seven fresh-context passes; every 🔴 was fixed with a test. Nits answered rather than changed:_get_table_entity. Folding both into one helper would change single-table lookups this PR otherwise leaves alone; the ADR v3 amendment ties the two together.test_resolver.pynext to the existing dbt-against-real-BigQuery-resolver tests, because only that file has the fake HTTP transport.Decision check: adds v3 to
docs/decisions/2026-11-03-bigquery-daily-shards-use-stable-logical-tables.md.Bug fix: I have added a test that covers the exact scenario we are fixing.
🤖 Generated with Claude Code