fix(schema_loader): quote case-sensitive column names in external models - #6099
Open
ReguiguiMohamed wants to merge 1 commit into
Open
ReguiguiMohamed wants to merge 1 commit into
ReguiguiMohamed wants to merge 1 commit into
Conversation
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>
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
Preserve column names when generating external models. PostgreSQL
"ID"was loaded asid.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_columnscovers Postgres, Snowflake and ClickHouse. It checks the written keys and the round trip throughcreate_external_model.pytest tests/core/test_schema_loader.py: 11 passedpytest tests/core/test_model.py -k external: 4 passedpytest tests/core/linter/test_builtin.py tests/lsp tests/core/test_schema_loader.py -m "not slow and not docker": 76 passedChecklist
make styleand fixed any issues (ranmake py-stylein WSL, covering every configured hook)make fast-test)git commit -s) per the DCO