Feat: allow overriding the dialects' normalization strategies#2779
Feat: allow overriding the dialects' normalization strategies#2779georgesittas merged 8 commits intomainfrom
Conversation
|
|
||
| The default model kind is `VIEW` unless overridden with the `kind` key. For more information on model kinds, refer to [model concepts page](../concepts/models/model_kinds.md). | ||
|
|
||
| ##### Identifier resolution |
| # applied to the DuckDB dialect globally | ||
| if "normalization_strategy" in str(self.config.dialect): | ||
| dialect = Dialect.get_or_raise(self.config.dialect) | ||
| type(dialect).NORMALIZATION_STRATEGY = dialect.normalization_strategy |
There was a problem hiding this comment.
So I can't have different normalization strategies for the same dialect? Furthermore it can't be overridden on per model basis? Should this be a top-level config then instead of being a part of a dialect? Feels a little misleading otherwise.
There was a problem hiding this comment.
So I can't have different normalization strategies for the same dialect?
That's right - but it seems reasonable to me, because you can only have a single default strategy for a given dialect. This simply makes the default_dialect override that default globally for said dialect, but it can be overridden on a model basis, so if you do dialect duckdb,normalization_strategy=... in the model meta, then I'm pretty sure that should take precedence over the class constant set here.
There was a problem hiding this comment.
So I can't have different normalization strategies for the same dialect?
Ah, I guess you were asking if you can override that strategy per model? If so, my answer may seem a bit contradictory. You can have different normalization strategies for the same dialect, e.g. if you override it in a model.
EDIT: clarified.
There was a problem hiding this comment.
sorry i'm confused, can you elaborate?
There was a problem hiding this comment.
- You can set
dialect: foo,normalization_strategy=...at the model defaults config level. This will monkey patch itsNORMALIZATION_STRATEGYclass constant, so it applies globally. - You can override this behavior per model by doing e.g.
dialect foo,normalization_strategy=...
There was a problem hiding this comment.
I'm still confused though. Wouldn't setting it in a model still override the strategy globally?
There was a problem hiding this comment.
how would it work if you set the model config to normarizaltion=x. would that get propogated to the engine adapter?
There was a problem hiding this comment.
Wouldn't setting it in a model still override the strategy globally?
Nope, because it gets stored as an attributed in the dialect and we ignore the NORMALIZATION_STRATEGY constant (see constructor). So there's no global overriding.
how would it work if you set the model config to normarizaltion=x. would that get propogated to the engine adapter?
If you do this at the model default config, then the dialect will be patched => the engine adapter's dialect will also have its strategy changed. This was the main motivation behind the patching.
If we didn't patch it, then setting normalization=.. in the project config would override the strategy of the dialect stored in the config, but not the one stored in the engine adapter, because we don't really pass the config's dialect to the adapters.
No description provided.