Skip to content

fix(dq): allow attaching test cases to nested columns (backport 2.0 #36385) - #36874

Merged
TeddyCr merged 3 commits into
open-metadata:2.0from
TeddyCr:backport/2.0/pr-36385
Nov 2, 2026
Merged

TeddyCr merged 3 commits into
open-metadata:2.0from
TeddyCr:backport/2.0/pr-36385

Conversation

@TeddyCr

@TeddyCr TeddyCr commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

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.0 tip; the original PR's delta was applied and then verified hunk-by-hunk (sorted ±line diff per file — all files identical except TestCaseResourceIT.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 walking Column.children. FQN-split so a column literally named a.b arriving 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; all keeps its meaning.
  • TestCaseRepository.validateColumnTestCase and validateDimensionColumns route through the new validation, so nested links attach via the API and a truly missing nested path still returns 400.
  • Tag inheritance (fetchAndSetTestSuiteTags bulk site + inheritTags) resolves nested columns, so tags on nested sub-columns now surface on their test cases.
  • CSV round-trip (convertFQNToEntityLink): exports the full quoted remaining FQN path (address.city, per-segment quoteName) instead of truncating nested paths.
  • PIIMasker resolves the test-case's target column through the same walk.
  • Ingestion runner (test_case_runner.py filter_incompatible_test_cases): looks up the column through the same dotted-path resolution, so a nested-column link neither crashes the runner with StopIteration nor mismatches columns.

2.0-specific adaptations (why this is a controlled backport, not a pure cherry-pick)

  1. 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. The post_testOnUnsupportedNestedColumnType_4xx IT was removed accordingly — verified live that it could not pass on 2.0 (2.0 has no create-time supportedDataTypes check even for top-level columns). The other two new nested-column ITs pass unchanged.
  2. 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 (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.
  3. TestCaseResourceIT.java: ported the three main-only private helpers the new tests call (listTestCaseResults, tableEntityLink, idsOf) plus the TestCaseResult import.
  4. ingestion/src/metadata/generated: regenerated from 2.0 schemas before running pytest.

Type of change:

  • Bug fix

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 on main). 2.0 differences are limited to the four adaptations listed above; each was verified against the 2.0 tree (grep for the caller classes/symbols returned zero hits on 2.0 before they were dropped, and the ported helpers were copied verbatim from main's TestCaseResourceIT).

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

  • A column-level test case whose entityLink targets a nested column (<#E::table::…::columns::address.city>) is accepted by the API (200).
  • A link pointing at a genuinely missing nested path still returns 400.
  • The ingestion runner filters (not crashes on) nested-column links when checking data-type compatibility, and fails a single link whose column is gone from the table instead of failing the whole runner.
  • Dotted literal column names (a.b as one segment) resolve.

Unit tests

  • Added unit tests.
  • Files added/updated: 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

  • Files added/updated: openmetadata-integration-tests/.../tests/TestCaseResourceIT.java — two new tests: post_nestedColumnLevelTest_200_OK, post_testWithInvalidNestedColumn_4xx.
  • Run locally via testcontainers (default Postgres dialect):
    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-service build — first attempt against the Maven-Central 2.0.8 jar 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

  • Not applicable (no connector changes).

Playwright (UI) tests

  • Not applicable (no UI changes).

Verification runs on this commit (847f6c1c2be)

  • env/bin/python -m pytest tests/unit/data_quality/test_test_case_runner.py → 5 passed
  • mvn test -pl openmetadata-service -Dtest='ColumnUtilTest,PIIMaskerTest' → 35 tests, 0 failures
  • mvn 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:apply clean 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:

  • 🔴 the original PR's 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.
  • 🟡 (accepted, pre-existing on merged main): no end-to-end test covers TableRepository ancestor resolution behind the single-column profile GET — all new PIIMaskerTest cases feed hand-built ancestors; noted here so it isn't lost.

UI screen recording / screenshots:

Not applicable — no UI changes.

Checklist:

@TeddyCr
TeddyCr requested review from a team as code owners November 2, 2026 19:02
@TeddyCr
TeddyCr requested review from mohityadav766 and stout-yeoman and removed request for a team November 2, 2026 19:02
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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 skip-pr-checks label.

@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Nov 2, 2026
…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.
@TeddyCr
TeddyCr force-pushed the backport/2.0/pr-36385 branch from fc60118 to 847f6c1 Compare November 2, 2026 19:06
@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs and removed safe to test Add this label to run secure Github workflows on PRs labels Nov 2, 2026
@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs and removed safe to test Add this label to run secure Github workflows on PRs labels Nov 2, 2026
continue

if column.dataType not in test_definition.supportedDataTypes:
if column.dataType not in (test_definition.supportedDataTypes or []):

@gitar-bot gitar-bot Bot Nov 2, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ 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 👍 / 👎

@gitar-bot

gitar-bot Bot commented Nov 2, 2026

Copy link
Copy Markdown
Code Review ⚠️ Changes requested 0 closed / 1 findings

🔴 High risk · Nested-column PII masking and profile resolution now govern exposure of statistics and test-case details; a path or tag mismatch could reveal sensitive data.

Backports the nested-column test case attachment fix (resolving dotted column paths through Column.children) to the 2.0 branch, along with tag inheritance, CSV export, PII masking, and ingestion runner updates. Changes requested: the filter_incompatible_test_cases guard now treats a missing supportedDataTypes as an empty list, so every column test whose definition declares no data types is marked incompatible and dropped instead of kept. Treat a missing list as no restriction and restore the unit test covering that case.

⚠️ Bug: None supportedDataTypes now rejects every column test as incompatible

📄 ingestion/src/metadata/data_quality/processor/test_case_runner.py:424-433

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:
🤖 Prompt for agents
Code Review: Backports the nested-column test case attachment fix (resolving dotted column paths through `Column.children`) to the 2.0 branch, along with tag inheritance, CSV export, PII masking, and ingestion runner updates. Changes requested: the `filter_incompatible_test_cases` guard now treats a missing `supportedDataTypes` as an empty list, so every column test whose definition declares no data types is marked incompatible and dropped instead of kept. Treat a missing list as no restriction and restore the unit test covering that case.

1. ⚠️ Bug: None supportedDataTypes now rejects every column test as incompatible
   Files: ingestion/src/metadata/data_quality/processor/test_case_runner.py:424-433

   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.

   Fix (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:

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

@sonarqubecloud

sonarqubecloud Bot commented Nov 2, 2026

Copy link
Copy Markdown

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ingestion safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants