Skip to content

fix(schema_loader): quote case-sensitive column names in external models - #6099

Open
ReguiguiMohamed wants to merge 1 commit into
SQLMesh:mainfrom
ReguiguiMohamed:fix/external-models-quote-case-sensitive-columns
Open

ReguiguiMohamed wants to merge 1 commit into
SQLMesh:mainfrom
ReguiguiMohamed:fix/external-models-quote-case-sensitive-columns

Conversation

@ReguiguiMohamed

Copy link
Copy Markdown
Contributor

Description

Preserve column names when generating external models. PostgreSQL "ID" was loaded as id.

Builds on @devtechedge's closed PR #6059, using SQLGlot identifier serialization and adding Snowflake and ClickHouse coverage.

Fixes #6058

Test Plan

test_create_external_models_quotes_case_sensitive_columns covers Postgres, Snowflake and ClickHouse. It checks the written keys and the round trip through create_external_model.

  • pytest tests/core/test_schema_loader.py: 11 passed
  • pytest tests/core/test_model.py -k external: 4 passed
  • pytest tests/core/linter/test_builtin.py tests/lsp tests/core/test_schema_loader.py -m "not slow and not docker": 76 passed

Checklist

  • I have run make style and fixed any issues (ran make py-style in WSL, covering every configured hook)
  • I have added tests for my changes (if applicable)
  • All existing tests pass (make fast-test)
  • My commits are signed off (git commit -s) per the DCO

create_external_models wrote column names bare, so a Postgres column
"ID" was read back as id. A name is now quoted only when the loader's
identifier normalization would change it. Names that already round-trip
are written as before.

Before the fix the new test failed with '"ID"' != 'ID' on Postgres and
'"lower_case"' != 'lower_case' on Snowflake.

Fixes SQLMesh#6058

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.

create_external_models writes case-sensitive column names unquoted, so projects with quoted (uppercase) PostgreSQL identifiers fail the linter

1 participant