Fixes #28710: dbt test case uses test case name as TestDefinition instead of dbt test type#28927
Fixes #28710: dbt test case uses test case name as TestDefinition instead of dbt test type#28927ulixius9 wants to merge 1 commit into
Conversation
dbt test cases were created with both name and testDefinition populated from manifest_node.name, so every test case got its own single-use TestDefinition named after the test case instead of referencing the actual dbt test type (e.g. unique, not_null) from manifest_node.test_metadata.name. Resolve the TestDefinition name from test_metadata.name for generic tests, falling back to the node name for singular tests and source freshness checks which have no test_metadata. Test cases of the same type now share a single TestDefinition. Fixes #28710 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
❌ 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 |
Code Review 👍 Approved with suggestions 0 resolved / 1 findingsUpdates dbt ingestion to resolve TestDefinition names based on the dbt test type instead of the test case name, ensuring shared definitions for identical test types. This change cleans up the Test Definitions list while maintaining backward compatibility for existing test cases. 💡 Edge Case: Shared TestDefinition entityType fixed by first test of a type📄 ingestion/src/metadata/ingestion/source/database/dbt/metadata.py:1410-1424 📄 ingestion/src/metadata/ingestion/source/database/dbt/dbt_utils.py:691-699 With this change, all dbt tests of the same type now share a single 🤖 Prompt for agentsOptionsDisplay: compact → Showing less information. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
There was a problem hiding this comment.
Pull request overview
Fixes dbt ingestion so OpenMetadata TestCase.testDefinition is derived from the dbt test type (manifest_node.test_metadata.name) instead of the per-test-case node name, reducing TestDefinition entity pollution and making the UI “Test Type” accurate.
Changes:
- Introduces
get_dbt_test_definition_name()helper and uses it when creating dbtTestDefinitionandTestCaseentities. - Updates dbt ingestion to dedupe
TestDefinitionby test type (when available). - Adds unit tests validating the new test-definition naming behavior for generic and singular tests.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| ingestion/src/metadata/ingestion/source/database/dbt/dbt_utils.py | Adds helper to compute the TestDefinition name for dbt tests. |
| ingestion/src/metadata/ingestion/source/database/dbt/metadata.py | Switches TestDefinition / TestCase.testDefinition to use the helper instead of manifest_node.name. |
| ingestion/tests/unit/test_dbt_test_definition.py | Adds regression tests for deriving TestDefinition from dbt test type. |
|
🔴 Playwright Results — 1 failure(s), 12 flaky✅ 4271 passed · ❌ 1 failed · 🟡 12 flaky · ⏭️ 88 skipped
Genuine Failures (failed on all attempts)❌
|



Describe your changes:
Fixes #28710
dbt ingestion created OpenMetadata TestCases with both
nameandtestDefinitionpopulated frommanifest_node.name. As a result:unique_customers_customer_id) instead of the dbt test type (e.g.unique).TestDefinitionentity was created per test case instead of one shared definition per dbt test type, polluting the Test Definitions list.Fix: add
get_dbt_test_definition_name()indbt_utils.py, which resolves the definition name frommanifest_node.test_metadata.name(the dbt test type) and falls back tomanifest_node.namefor singular tests and source freshness checks, which have notest_metadata. Bothcreate_dbt_tests_definitionandcreate_dbt_test_casenow use it, so all test cases of the same type share oneTestDefinition.This also handles namespaced package tests correctly — e.g. a
dbt_utils.equal_rowcounttest resolves to anequal_rowcountdefinition.Backward compatibility: test cases ingested before this fix are skipped on re-ingestion (existing behavior — test cases are only created if absent), so they keep their old per-case definitions. Only newly created test cases get the shared type-based definition. Deleting the old test cases and re-running the ingestion migrates them.
Tests:
Use cases covered
unique,not_null,accepted_values,relationships) → TestCase references aTestDefinitionnamed after the dbt test typedbt_utils.equal_rowcount) → resolves toequal_rowcounttest_metadata) → falls back to the node name (unchanged behavior)TestDefinitioncreatedUnit tests
ingestion/tests/unit/test_dbt_test_definition.py(6 tests covering the helper, test case creation, definition creation, and dedup)test_dbt.py,test_dbt_ingest.py,test_dbt_http_config.py— 175/175Backend integration tests
Ingestion integration tests
Playwright (UI) tests
Manual testing performed
docker/development/docker-compose.ymltestDefinitionequal to the test case name and 20 single-use TestDefinitions were createdunique,not_null,accepted_values,relationships)dbt_utils.equal_rowcount): all test cases show the correct Test Type in the UI; data models, lineage, and descriptions unaffectedUI screen recording / screenshots:
Not applicable (ingestion-only change; UI now displays the correct Test Type).
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.🤖 Generated with Claude Code