However, the models will be normalized at the model_defaults.dialect even if the default_gateway is set to a different engine, which can lead to issues / inefficiencies e.g Redshift's INFORMATION_SCHEMA stores the tables as lower-case, so with Snowflake's upper-case normalization we'll fail to find the tables/views.
This PR adds support for model_defaults under gateways which override the global dialect, e.g:
# Snowflake dialect, Redshift gateway without model_defaults
❯ sqlmeshrendervaggelis.test_model
[WARNING] TheredshiftengineisnotrecommendedforstoringSQLMeshstateinproductiondeployments. Pleaseseehttps://sqlmesh.readthedocs.io/en/stable/guides/configuration/#state-connection for a list of recommended engines and more information.SELECT"COL"AS"COL"FROM"TBL"AS"TBL"# Snowflake dialect, Redshift gateway with model_defaults.dialect: snowflake, normalization_strategy=case_insensitive
❯ sqlmeshrendervaggelis.test_model
[WARNING] TheredshiftengineisnotrecommendedforstoringSQLMeshstateinproductiondeployments. Pleaseseehttps://sqlmesh.readthedocs.io/en/stable/guides/configuration/#state-connection for a list of recommended engines and more information.SELECT"col"AS"col"FROM"tbl"AS"tbl"
VaggelisD
changed the title
Feat: Set normalization strategy according to used gateway
Feat: Add model defaults support per gateway configuration
Feb 24, 2025
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
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.
Users can employ different gateways on the same project:
However, the models will be normalized at the model_defaults.dialect even if the default_gateway is set to a different engine, which can lead to issues / inefficiencies e.g Redshift's INFORMATION_SCHEMA stores the tables as lower-case, so with Snowflake's upper-case normalization we'll fail to find the tables/views.
This PR adds support for model_defaults under gateways which override the global dialect, e.g:
This enables the following behavior: