Repository navigation
Conversation
…erences When the tested model's table is not in OpenMetadata it is dropped from the test's upstreams, and the primary-table fallback picked upstream_list[0] - the relationships test's to: table, which dbt lists first. The test was attached to that table with a column it does not have and the server rejected it with 400 Invalid column name, or it landed on the wrong table silently when the column happened to exist on both. The fallback now picks the first upstream that is not the referenced table and skips the test with a warning when none is left.
Trust a non-to: candidate only when exactly one remains, so an unresolved tested model with several candidates (an ephemeral model expanded into its parents) is skipped rather than attached to an arbitrary upstream. Log the skip from generate_entity_link so it is emitted once per test, naming the model instead of its raw Jinja.
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
The skip also happens when several candidate tables exist in OpenMetadata, so blaming a missing or filtered table sent readers looking for a table that is there.
Code Review ✅ Approved 🟡 Medium risk 1 closed / 1 findingsChanging dbt relationship-test resolution to skip missing or ambiguous models could reduce reported test coverage, though it prevents misattachment. Stops dbt ✅ 1 closed✅ Quality: Skip warning misstates the cause when the fallback is ambiguous
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 |
Describe your changes:
Fixes #38654
A dbt
relationshipstest was attached to the table it references (to:) whenever the tested model's table was not in OpenMetadata.parse_upstream_nodes_with_namesdrops upstreams it can't find. Thenget_dbt_test_primary_table_fqncould resolve neither themodelref nor a single non-to:candidate, and fell back toupstream_list[0]. dbt lists the referenced parent first, so that is theto:table. The server then rejected the test with400 Invalid column name <fk_col>on every run, which left the pipeline at Partial Success. If the column name existed on both tables, the test landed on the wrong table silently.When the tested model doesn't resolve, the
to:table is now excluded and a remaining upstream is used only if exactly one is left. If none or several are left, the test is skipped with one warning per test that names the model (missing or filtered out). Several remaining candidates happen, for example, when an ephemeral model is expanded into its parents. Tests without ato:(singular tests, other generic tests, freshness) keep the first-upstream fallback. This is a follow-up to #28911 / #30606, which fixed the alias/case mismatch but kept theupstream_list[0]fallback.Seen in a production dbt Cloud + Snowflake run: 3 of its 12 nightly
Invalid column namefailures came from this path. The other 9 were schema.yml columns the tables don't have, and the server correctly rejects those.Type of change:
High-level design:
N/A — small change (one function in
dbt_utils.pyplus its tests).Tests:
Use cases covered
to:table and rejected with a 400).to:table.source()namespaces, single-upstream tests.Unit tests
test_dbt_relationships_test_skipped_when_tested_table_not_in_openmetadataandtest_dbt_relationships_test_skipped_when_tested_table_is_ambiguousiningestion/tests/unit/test_dbt.py. Both fail onmainand pass with the fix.pytest tests/unit/test_dbt.py tests/unit/test_dbt_python_models.py tests/unit/test_dbt_test_definition.py tests/unit/test_dbt_test_descriptions.py: 377 passed, 1 failed. The failure isTestStorageStreamingBehavior::test_gcs_passes_generator_to_grouping(module 'google.cloud' has no attribute 'storage'), because my local venv lacksgoogle-cloud-storage; it is unrelated to this change.ruff check/ruff format --checkon the changed files: clean.Backend integration tests
Ingestion integration tests
tests/integration/importsdbt_utils.Playwright (UI) tests
Manual testing performed
to:table whileUnable to find the table '<tested model>'was logged for the tested model.generate_entity_linkon the 2.0.9 code with a synthetic relationships test node. With the tested model missing from upstreams, it returned the referenced table's link; with the fix, it returns[].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: I updated the migration scripts or explained why it is not needed. — N/A, no schema change.
For a UI feature or feature task: … — N/A, no UI.
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.Reviewed
9f338dabe16with a fresh-context reviewer. The first pass (6a022f8555e) found 0 🔴 and 2 🟡: an arbitrary pick among several candidates, and a duplicate warning that showed raw Jinja. Both are fixed in9f338dabe16, and the re-review found nothing. Known limitation, unchanged frommain: an ephemeral tested model with exactly one parent still attaches to that parent.Decision check — N/A: no new contract, default or ordering. The rule "never attach to the
to:table" is stated in the code docstring.I have added a test that covers the exact scenario we are fixing.
🤖 Generated with Claude Code