Repository navigation
fix(dq): allow attaching test cases to nested columns (backport 2.0 #36385) - #36874
Conversation
❌ 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 |
…pen-metadata#36385) Fixes open-metadata#36381. Port of open-metadata#36385 to the 2.0 release branch, with release-specific adaptations: - TestCaseDefinitionConformance (and its test) omitted: the class comes from open-metadata#35629 and does not exist on 2.0, so the supported-data-type conformance check does not exist either. The post_testOnUnsupportedNestedColumnType_4xx IT removed accordingly; the other two nested-column ITs pass unchanged. - ingestion/tests/unit/data_quality/test_test_case_runner.py added wholesale (never existed on 2.0), dropping the pre-existing test_filter_keeps_test_case_when_no_data_types_are_declared, whose supportedDataTypes=None guard (open-metadata#27718, open-metadata#32996) never landed on 2.0. All three PR-added tests kept. - TestCaseResourceIT: ported the three main-only private helpers the new tests call (listTestCaseResults, tableEntityLink, idsOf) plus the TestCaseResult import.
fc60118 to
847f6c1
Compare
| continue | ||
|
|
||
| if column.dataType not in test_definition.supportedDataTypes: | ||
| if column.dataType not in (test_definition.supportedDataTypes or []): |
There was a problem hiding this comment.
⚠️ Bug: None supportedDataTypes now rejects every column test as incompatible
With (test_definition.supportedDataTypes or []), a column-level test definition that declares no supportedDataTypes (None) makes column.dataType not in [] always True. Every test case using that definition gets marked failed with "is not compatible with column ... of type ..." and is dropped from execution. The crash is gone, but the test still never runs, and the error claims a type mismatch that doesn't exist. On main, the guard this commit is meant to mirror keeps the test case when no data types are declared (see the dropped test_filter_keeps_test_case_when_no_data_types_are_declared). The fix is to treat a missing list as "no restriction" and add that unit test to this backport.
Skip the type check when the definition declares no supported data types:
supported_data_types = test_definition.supportedDataTypes
if supported_data_types and column.dataType not in supported_data_types:
Was this helpful? React with 👍 / 👎
Code Review
|
| Compact |
|
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source
|



Backport of PR #36385 to the 2.0 release branch
Describe your changes:
Fixes #36381
Port of #36385 ("fix(dq): allow attaching test cases to nested columns") to the 2.0 release branch. Branch cut cleanly from the
2.0tip; the original PR's delta was applied and then verified hunk-by-hunk (sorted ±line diff per file — all files identical exceptTestCaseResourceIT.java, which diverges only by the documented 2.0 adaptations below).What changed (as in the original PR)
ColumnUtil.resolveColumnByPath/validateColumnPath(new): resolve a dotted path by walkingColumn.children. FQN-split so a column literally nameda.barriving as"a.b"stays one segment; case-exact match first, case-insensitive fallback; a dotted literal column name arriving unquoted (legacy links) still resolves as a whole name when the segment walk fails;allkeeps its meaning.TestCaseRepository.validateColumnTestCaseandvalidateDimensionColumnsroute through the new validation, so nested links attach via the API and a truly missing nested path still returns 400.fetchAndSetTestSuiteTagsbulk site +inheritTags) resolves nested columns, so tags on nested sub-columns now surface on their test cases.convertFQNToEntityLink): exports the full quoted remaining FQN path (address.city, per-segmentquoteName) instead of truncating nested paths.PIIMaskerresolves the test-case's target column through the same walk.test_case_runner.pyfilter_incompatible_test_cases): looks up the column through the same dotted-path resolution, so a nested-column link neither crashes the runner withStopIterationnor mismatchescolumns.2.0-specific adaptations (why this is a controlled backport, not a pure cherry-pick)
TestCaseDefinitionConformance(and its test) omitted. The class comes from Fixes 35274: Check test parameters against their definitions and fix open-window and boolean-set runs #35629 and does not exist on 2.0, so the supported-data-type conformance check does not exist there either. Thepost_testOnUnsupportedNestedColumnType_4xxIT was removed accordingly — verified live that it could not pass on 2.0 (2.0 has no create-timesupportedDataTypescheck even for top-level columns). The other two new nested-column ITs pass unchanged.ingestion/tests/unit/data_quality/test_test_case_runner.pyadded wholesale (never existed on 2.0), dropping the pre-existingtest_filter_keeps_test_case_when_no_data_types_are_declared, whosesupportedDataTypes=Noneguard (Generic DQ test definitions missing for unspecified data types in Collate #27718, Fixes #27718: Generic and NUMERIC test definitions missing from the Add Test Case dropdown #32996) never landed on 2.0. All three PR-added tests kept.TestCaseResourceIT.java: ported the three main-only private helpers the new tests call (listTestCaseResults,tableEntityLink,idsOf) plus theTestCaseResultimport.ingestion/src/metadata/generated: regenerated from 2.0 schemas before running pytest.Type of change:
High-level design:
Large PR (10 files). The design is unchanged from the original PR — see its description there; the corresponding
docs/decisions/record is not backported (it stays onmain). 2.0 differences are limited to the four adaptations listed above; each was verified against the 2.0 tree (grepfor the caller classes/symbols returned zero hits on 2.0 before they were dropped, and the ported helpers were copied verbatim frommain'sTestCaseResourceIT).No schema, migration, or index-mapping changes are carried in this backport (the schemas involved already exist on 2.0 in the same shape).
Tests:
Use cases covered
<#E::table::…::columns::address.city>) is accepted by the API (200).a.bas one segment) resolve.Unit tests
ingestion/tests/unit/data_quality/test_test_case_runner.py(new on 2.0 — 5 tests),openmetadata-service/.../jdbi3/ColumnUtilTest.java(17 tests),openmetadata-service/.../security/mask/PIIMaskerTest.java(18 tests).Backend integration tests
openmetadata-integration-tests/.../tests/TestCaseResourceIT.java— two new tests:post_nestedColumnLevelTest_200_OK,post_testWithInvalidNestedColumn_4xx.mvn test -pl openmetadata-integration-tests -Dtest='TestCaseResourceIT#post_nestedColumnLevelTest_200_OK+post_testWithInvalidNestedColumn_4xx'→ 2 run, 0 fail, 0 error.(Against this branch's
openmetadata-servicebuild — first attempt against the Maven-Central2.0.8jar reproduced the original bug,Invalid column name address.city, and confirmed the ITs only pass with the fix in the server, i.e. they fail without it.)Ingestion integration tests
Playwright (UI) tests
Verification runs on this commit (
847f6c1c2be)env/bin/python -m pytest tests/unit/data_quality/test_test_case_runner.py→ 5 passedmvn test -pl openmetadata-service -Dtest='ColumnUtilTest,PIIMaskerTest'→ 35 tests, 0 failuresmvn test -pl openmetadata-integration-tests -Dtest='TestCaseResourceIT#post_nestedColumnLevelTest_200_OK+post_testWithInvalidNestedColumn_4xx'→ 2 run, 0 fail, 0 error (server rebuilt from this branch)mvn spotless:applyclean on both touched Java modules; ruff clean on ingestion.Self-review (against
REVIEW.md)Fresh-eyes review pass on the pre-fix SHA; final verified commit
847f6c1c2be:docs/decisions/record would have named two guards that do not exist on 2.0 (TestCaseDefinitionConformance, the unsupported-nested-type IT) → resolved by not backporting the decision record; the operative-2.0-guards note lives in the 2.0 adaptation list above.main): no end-to-end test coversTableRepositoryancestor resolution behind the single-column profile GET — all newPIIMaskerTestcases feed hand-built ancestors; noted here so it isn't lost.UI screen recording / screenshots:
Not applicable — no UI changes.
Checklist:
Fixes #36381above. (Title follows the 2.0 backport convention… (backport 2.0 #36385)used by e.g. fix(ui): link only http(s) URLs in the summary panel and sanitize the editor's final Markdown pass (backport 2.0 #36806) #36815.)