-
Notifications
You must be signed in to change notification settings - Fork 321
Fix!: Dont normalize aliases in merge and when matched #5014
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1b322be
589b229
f9be331
f3a64fe
632faea
4e5d3da
c3941c6
46073d0
79e07fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -478,10 +478,9 @@ def _when_matched_validator( | |
| v = v[1:-1] | ||
|
|
||
| v = t.cast(exp.Whens, d.parse_one(v, into=exp.Whens, dialect=dialect)) | ||
| else: | ||
| v = t.cast(exp.Whens, v.transform(d.replace_merge_table_aliases, dialect=dialect)) | ||
|
|
||
| return validate_expression(v, dialect=dialect) | ||
| v = validate_expression(v, dialect=dialect) | ||
| return t.cast(exp.Whens, v.transform(d.replace_merge_table_aliases, dialect=dialect)) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously we only ran the However, applying it regardless like you do here will transparently "fix" what was in state, right? So that when people upgrade SQLMesh, everything should still match
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes that was my thinking behind it to foolproof it |
||
|
|
||
| @field_validator("merge_filter", mode="before") | ||
| def _merge_filter_validator( | ||
|
|
@@ -497,10 +496,9 @@ def _merge_filter_validator( | |
| if isinstance(v, str): | ||
| v = v.strip() | ||
| v = d.parse_one(v, dialect=dialect) | ||
| else: | ||
| v = v.transform(d.replace_merge_table_aliases, dialect=dialect) | ||
|
|
||
| return validate_expression(v, dialect=dialect) | ||
| v = validate_expression(v, dialect=dialect) | ||
| return v.transform(d.replace_merge_table_aliases, dialect=dialect) | ||
|
|
||
| @property | ||
| def data_hash_values(self) -> t.List[t.Optional[str]]: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It took me some time to grok this but I see why it works.
quoted=Trueis the key part to prevent it being un-done later.This essentially ensures that everything is uppercase regardless of the engine's normalization strategy, which lines up with what
EngineAdapter._mergeuses.EngineAdapter._mergeproduces an unquoted uppercase value, which gets quoted by default duringEngineAdapter.execute, which is why it needs to either be uppercase here or normalized inEngineAdapter._merge