Validate relationship column pair counts - #307
Open
LiangRuoShui wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The OSI spec requires
from_columnsandto_columnsin 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
validation/validate.pyfor mismatchedfrom_columns/to_columnslengths.[Relationship]error that includes the relationship name, model name, and both column counts.Tests added/updated
validation/tests/test_validate.py::test_validate_references_rejects_mismatched_relationship_column_countsvalidation/tests/test_validate.py::test_validate_references_accepts_matching_relationship_column_countsVerification
uv run --with pytest --with pyyaml --with jsonschema --with sqlglot pytest validation/tests/test_validate.py -quv run validation/validate.py examples/tpcds_semantic_model.yaml2 from_columns but 1 to_columns.