Skip to content

Fixes 38703: Make dbt BigQuery wildcard sources upstream of every table they read - #38704

Merged
ulixius9 merged 3 commits into
mainfrom
ulixius9/openmetadata-ingestion-log-analysis
Nov 26, 2026
Merged

ulixius9 merged 3 commits into
mainfrom
ulixius9/openmetadata-ingestion-log-analysis

Conversation

@ulixius9

@ulixius9 ulixius9 commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

Fixes #38703

Backport to 2.0: #38707.

A dbt source whose identifier is a BigQuery wildcard table, such as GA4's events_*, never produced dbt lineage. dbt looks up source identifiers literally (#35683), so * was escaped and the lookup asked for a table named exactly events_*. Nothing matched, so the parent was dropped from every model that reads it, even with shardedTables cataloging the shards as events_yyyymmdd / events_intraday_yyyymmdd. create_dbt_lineage already 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):

  • Data model: keeps the wildcard FQN as an upstream instead of looking it up as one table.
  • Expansion: create_dbt_lineage turns it into one edge per table BigQuery would read, including both the daily and intraday families.
  • Lookup order: the same as every other dbt node: catalogMapping database in the configured service, then in any service, then the manifest database, then any service when searchAcrossDatabases is set.
  • Unmatched wildcard: reported, and gets no edge. It is never looked up as a single table, because that would link whichever table the pattern hit first.
  • Incomplete match: a match over the 100-candidate limit, date-constrained (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.
  • Run cache: each wildcard is expanded once per run.
  • Unchanged: tests and exposures still need exactly one table, so they keep the literal lookup. Other engines keep the identifier literal; a real * 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:

  • Bug fix

High-level design:

  • TableBindingResolution.supports_wildcard_tables: a class attribute, False by default and True on BigQueryTableBindingResolution. 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): only yield_data_models passes True. 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 in yield_data_models. An outcome is the matched tables, or None when the match was incomplete. _overrides_lineage derives 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.
  • Rejected: matching the escaped literal events_\* to just the events_ family inside the BigQuery resolver. BigQuery's events_* also reads events_intraday_* and any events_… table, so linking one family would be a guess.
  • Rejected: expanding at parse time and dropping only the failing parent. With overrideLineage, the model's other edges would then delete the wildcard's earlier edges.

Tests:

Use cases covered

  • A model reading events_* gets an edge from both the events_ and events_intraday_ shard families, and the edges carry the model SQL.
  • The same model behind an ephemeral staging model.
  • A wildcard matching more than 100 tables, or date-constrained (events_2026*), with and without overrideLineage: the model's other parent (orders) still links, and neither lineage stage overrides.
  • A complete wildcard lets both stages override.
  • 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.
  • An unmatched wildcard is reported, takes no single table, and still lets the model override.
  • One expansion per run, and the cache is reset between runs.
  • Tests and exposures don't expand wildcards. Non-BigQuery engines keep literal * identifiers: no upstream, and the literal table still gets its lineage edge.

Unit tests

  • I added unit tests for the new/changed logic.
  • Files added/updated: ingestion/tests/unit/entity_resolution/test_resolver.py (test_dbt_wildcard_source_*, test_dbt_incomplete_wildcard_source_*, test_dbt_complete_wildcard_source_*), and ingestion/tests/unit/test_dbt.py (TestDbtSourceIdentifiers: the new yield_data_models wiring test, plus a lineage assertion added to the literal-identifier test).
  • Each new test was checked to fail when the line it guards is reverted (the gate, the yield_data_models flag, the ephemeral pass-through, the override decision in each stage, the cache and its reset, the catalogMapping and cross-service lookups, the several-services check, the unmatched-wildcard handling, and the literal-* exclusion).
  • Local run, on Python 3.11 before the rebase onto current 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.
  • Coverage %: not measured.

Backend integration tests

  • Not applicable (no backend API changes).

Ingestion integration tests

  • I ran the integration tests covering my changed files locally.
  • Not run: no dbt or BigQuery integration test drives create_dbt_lineage against a wildcard source. The merge queue runs tests/integration/.

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

  1. Found on a real dbt Cloud + BigQuery ingestion run (OpenMetadata 2.0.10, shardedTables on). Every GA4 events_* / users_* source and the audit-log wildcard sources logged Unable 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 …_yyyymmdd families, so sharding itself worked.
  2. Not yet re-run against that environment with this fix.

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 (the pr-checklist skill runs it) and fixed every 🔴 finding, or answered it on the line below.

    • Reviewed 06405454 (content-identical to this head after the rebase). Seven fresh-context passes; every 🔴 was fixed with a test. Nits answered rather than changed:
      • The run cache stores Table entities rather than ids. Its key count is the number of distinct wildcard sources in a project, typically a handful.
      • The wildcard lookup order repeats the single-table one in _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.
      • Wildcard tests live in test_resolver.py next 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

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
ulixius9 requested a review from a team as a code owner November 25, 2026 14:21
@ulixius9
ulixius9 requested review from mohittilala and a balanced review from Copilot November 25, 2026 14:21
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 26, 2026 05:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 26, 2026 05:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@gitar-bot

gitar-bot Bot commented Nov 26, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk

Expanding 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 events_* upstream of every table they read, expanding each into one lineage edge per matched shard across both daily and intraday families. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@ulixius9
ulixius9 merged commit bee5926 into main Nov 26, 2026
41 checks passed
@ulixius9
ulixius9 deleted the ulixius9/openmetadata-ingestion-log-analysis branch November 26, 2026 13:19
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dbt: BigQuery wildcard sources (events_*) never produce dbt lineage

3 participants