Skip to content

Validate relationship column pair counts - #307

Open
LiangRuoShui wants to merge 1 commit into
apache:mainfrom
LiangRuoShui:fix/validate-relationship-column-pairs
Open

Validate relationship column pair counts#307
LiangRuoShui wants to merge 1 commit into
apache:mainfrom
LiangRuoShui:fix/validate-relationship-column-pairs

Conversation

@LiangRuoShui

Copy link
Copy Markdown

Why

The OSI spec requires from_columns and to_columns in a relationship to have the same number of columns so each source column maps to one target column. The validator checked that relationship datasets existed, but did not enforce this cardinality rule, so invalid relationship definitions could pass validation and be silently truncated by downstream converters that zip the two arrays.

What changed

  • Added a relationship-level validation check in validation/validate.py for mismatched from_columns / to_columns lengths.
  • Report mismatches with a clear [Relationship] error that includes the relationship name, model name, and both column counts.
  • Added validation unit tests for both mismatched and matching relationship column arrays.

Tests added/updated

  • validation/tests/test_validate.py::test_validate_references_rejects_mismatched_relationship_column_counts
  • validation/tests/test_validate.py::test_validate_references_accepts_matching_relationship_column_counts

Verification

  • uv run --with pytest --with pyyaml --with jsonschema --with sqlglot pytest validation/tests/test_validate.py -q
  • uv run validation/validate.py examples/tpcds_semantic_model.yaml
  • Verified an invalid temporary OSI document now fails validation with 2 from_columns but 1 to_columns.

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.

1 participant