fix(model): keep quoting when normalizing column_descriptions keys - #5959
Open
ReguiguiMohamed wants to merge 1 commit into
Open
fix(model): keep quoting when normalizing column_descriptions keys#5959ReguiguiMohamed wants to merge 1 commit into
ReguiguiMohamed wants to merge 1 commit into
Conversation
_column_descriptions_validator built each key with part.this, which is the bare identifier string, so the quoted flag was gone before normalize_identifiers ran. A quoted key was then normalized as if it were unquoted, and on dialects where quoting makes a column case-sensitive the resulting name matched no column, so the description was dropped along with the rest of the table's comments. Normalize each part while it is still an identifier. Unquoted keys normalize exactly as before. Fixes SQLMesh#5943 Signed-off-by: ReguiguiMohamed <mohamedreguigui2004@gmail.com>
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.
Fixes #5943.
_column_descriptions_validatorbuilds each key with".".join(part.this for part in v.this.parts).part.thisis the bare identifier string, so thequotedflag is gone beforenormalize_identifiersruns, and the key is normalized as if it had never been quoted. On a dialect where quoting makes a column case-sensitive,"myColumn"becomesMYCOLUMN, matches no column, and gets dropped along with the rest of the table's comments.Normalizing each part while it is still an identifier fixes it. Unquoted keys normalize exactly as before, and the dict branch used by Python models is unchanged in behaviour.
Before, with
dialect snowflake:After:
{'myColumn': ...}.test_column_descriptions_quoted_identifiercovers both halves, a quoted key keeping its case and an unquoted one still normalizing, and fails on main withMYCOLUMN != myColumn.tests/core/test_model.pypasses in full (334).ruffandruff-formatpass.mypyon the changed module reports nothing.