Open
Conversation
…on, allows the initial join erroneosly forbidden
|
Last reviewed commit: "black / isort / type..." |
…ule as single-column PK (key column ∈ right join columns), make sure nested circular relationships are all surfaced at once. new tests added " "
…rcuit, remove redundant import - Allow unique_keys to validate joins even when primary_key is not declared (previously fell through to "no primary key metadata" error unconditionally) - Add `continue` after self-reference error to avoid redundant downstream errors - Remove redundant `import re` inside has_sql_transformation (already at module level) .... Generated with [Cortex Code](https://docs.snowflake.com/en/user-guide/cortex-code/cortex-code) Co-Authored-By: Cortex Code <noreply@snowflake.com>
…kflows Adds project-level CoCo configuration: - .cortex/skills/sst-validate: SST validation workflow - .cortex/skills/sst-test: Unit test workflow - .cortex/skills/sst-pr-review: PR review checklist - .cortex/agents/sst-validator.md: E2E validation agent - AGENTS.md: Project context for AI assistants .... Generated with [Cortex Code](https://docs.snowflake.com/en/user-guide/cortex-code/cortex-code) Co-Authored-By: Cortex Code <noreply@snowflake.com>
Contributor
Author
|
I'm on mobile so I can't confirm but wanted to flag in case you plan to merge -- I think the CoCo skills you added in the last commit (great idea) won't work on other ppl’s machines since they’re hard coded file paths to your cd |
…an hardcoded path
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.
Description
Aligns SST relationship validation with Snowflake semantic view relationship rules: referenced (right) join columns must match the model’s primary key or declared
meta.sst.unique_keys, with clearer multiline errors and direction hints. Fixes the case where catalog-declared unique keys were ignored and valid joins were rejected.Related Issue
Closes #119
Type of Change
Changes Made
validator.py: Surfaceunique_keysfrom dbt catalog (sm_tables) so relationship validation can treat them like Snowflake’s unique-key option for the referenced side.references.py:unique_keysset (set equality, order-independent).test_relationship_validation.py): unique_keys pass-through, self-ref, 2-node cycle, 3-node cycle, acyclic fan-out, composite PK column order, compositeunique_keyswhen PK differs, wrong unique subset still errors; existing assertions updated for new messaging where needed.Testing
pytest tests/unit/)Test Results
Unit tests (repo)
Manual (within an external dbt project)
Scenario A — will PASS after this PR (join on
unique_keys, not PK, on the referenced/right table)Catalog / model
table1(right / referenced):Model
table2(referencing) with composite PK, relationshipright_table=table1,left_table=table2, conditions equatinguser_id/calendar_date↔user_id/response_date(so the join is on the unique rather than the primary key in the right table)Before fix (representative
sst validateoutput — message implied UNIQUE could be valid, but validation still failed;unique_keysin catalog was ignored):After fix (same project / same YAML — join columns match
meta.sst.unique_keyson the right-hand model):Scenario B — should still FAIL, with a clearer error (right table PK not used; no
unique_keyscovering the join columns)Right table PK e.g.
cycle_id; relationship joins on columns likeuser_idandcycle_start_date_app_viewwithout a matchingunique_keysdeclaration.Example dbt models (generic
table1= left,table2= right for this failure case)table1— referencing / LEFT (composite PK matches the join grain you use on this side):table2— referenced / RIGHT: PK is not the join columns, and there is nometa.sst.unique_keysthat matches the join:Relationship (invalid):
left_table=table1,right_table=table2, conditions equatingtable1.user_id/table1.calendar_datetotable2.user_id/table2.cycle_start_date_app_view. Validation should still fail with a clear error (sample output below).Representative output (
table2on the right, PKcycle_id, join onuser_id+cycle_start_date_app_view; SST shows logical table names in uppercase):Checklist
Code Quality
mypy snowflake_semantic_tools/passes)Documentation & Compatibility
Performance
Screenshots / Examples
See Test Results — unit commands plus manual
sst validatescenarios and expected exit codes / messages.Additional Notes
Not at this time.