Skip to content

fix(model): keep quoting when normalizing column_descriptions keys - #5959

Open
ReguiguiMohamed wants to merge 1 commit into
SQLMesh:mainfrom
ReguiguiMohamed:fix/column-descriptions-quoted-identifiers
Open

fix(model): keep quoting when normalizing column_descriptions keys#5959
ReguiguiMohamed wants to merge 1 commit into
SQLMesh:mainfrom
ReguiguiMohamed:fix/column-descriptions-quoted-identifiers

Conversation

@ReguiguiMohamed

Copy link
Copy Markdown

Fixes #5943.

_column_descriptions_validator builds each key with ".".join(part.this for part in v.this.parts). part.this is the bare identifier string, so the quoted flag is gone before normalize_identifiers runs, and the key is normalized as if it had never been quoted. On a dialect where quoting makes a column case-sensitive, "myColumn" becomes MYCOLUMN, 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:

descriptions: {'MYCOLUMN': 'comment for a case-sensitive column'}
columns     : ['myColumn']

After: {'myColumn': ...}.

test_column_descriptions_quoted_identifier covers both halves, a quoted key keeping its case and an unquoted one still normalizing, and fails on main with MYCOLUMN != myColumn.

tests/core/test_model.py passes in full (334). ruff and ruff-format pass. mypy on the changed module reports nothing.

_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>
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.

column_descriptions drops identifier quoting, breaking all column comments on case-sensitive columns

1 participant