Conversation
sqlmesh/dbt/context.py
Outdated
There was a problem hiding this comment.
Since we now need to handle dialect in the jinja, would it make sense to always pass in dialect here? It would simplify create_builtin_globals code.
There was a problem hiding this comment.
Also, do we want to pass in the default dialect? Wouldn't it make more sense to pass in the model dialect during to_sqlmesh in the model?
There was a problem hiding this comment.
We can't pass in self.default_dialect because target hasn't been set the first time this is called and we'll error.
I'm not following your second comment - where in to_sqlmesh can we modify the globals? Here?
https://github.com/TobikoData/sqlmesh/blob/b7c659e66b6eab5ec30a6f5d341937d8746de683/sqlmesh/dbt/model.py#L382
There was a problem hiding this comment.
@crericha I think this is only relevant in the context of dbt projects and doesn't apply to native projects, so not sure whether we need the dialect as a top-level argument.
sqlmesh/dbt/model.py
Outdated
There was a problem hiding this comment.
I'm not sure this is needed. Aren't we creating directly into the generic AST form and the sqlglot generator will handle transpiling for us? How is partitioned_by parsing handled for a native sqlmesh model?
There was a problem hiding this comment.
exp.to_column(val) is parsing the raw column string from the model definition and returning an expression. If someone includes dialect-specific characters, I think it will choke.
cluster_by is also parsing column names just below and passes a dialect, so maybe it not being here already is an oversight?
https://github.com/TobikoData/sqlmesh/blob/b7c659e66b6eab5ec30a6f5d341937d8746de683/sqlmesh/dbt/model.py#L377
Either way, this initial implementation is messy, so I'll clean it up and we can remove if it's not necessary.
c1ffc0f to
324b6b1
Compare
324b6b1 to
9ae6ebd
Compare
9f2ef2a to
738fa58
Compare
0d68419 to
738fa58
Compare
b4b3c54 to
370ae0e
Compare
370ae0e to
6ccf7b9
Compare
This PR allows dbt project models and tests to be written in a different SQL dialect than the target engine on which the project is being run.
A project has a default dialect - all models/tests without an explicitly configured dialect are assumed to be written in the default. In a dbt project without an explicit default dialect specified, the target engine dialect is the default.
Specify a default dialect other than the target engine in the
config.pyfile model defaults argumentSpecify dialects for individual models/tests in the standard way:
{{ config(dialect='bigquery') }}Limitations
time_columnto be specified in a different dialect than the model query itself. In dbt, kind-specific parameters are parsed with the model's dialect.