-
Notifications
You must be signed in to change notification settings - Fork 358
Closed as not planned
Description
required knowledge about dbt
- dbt uses profiles to manage connections with the engines. It can be stored at user home level (~/.dbt/profiles.yml) or at project level (my_project/profiles.yml).
- each profile defines a default schema name
- dbt models are referenced through their filename (
select foo from {{ ref('bar') }}). - the default schema used by dbt to write a model is <target_schema>_<custom_schema> (target == profile one / custom is the one that you can specify at model or project configuration level)
- dbt allows to override the default schema macro to change that behavior in jinja code
Comparison with SQLMesh
- SQLMesh defines Gateway & Environment to connect to engines
- Those concepts don't define a default schema
- The schema is defined at model level but it is also overridden when it's "applied" to isolate environments & physical/virtual level
Context
SQLMesh offers a dbt integration that allow to run directly the project but also to use them as part of the multi project integration.
However to map the SQLMesh to dbt approach, SQLMesh resolves the schema used by dbt to form the FQN that will be used for both model referencing (from model A to model B) and in tests.
The problem
As in SQLMesh the FQN is static, it's working as intended to define test but for dbt ... it's a problem.
It's also painful use with any feature that rely on selectors as switching profile changes the FQN.
Example
In following PR, I'm using a multi project integration and had to set the schema to dbt_cou but it's not referenced anywhere in my project because it's overridden through my profiles.yml
Some ideas to fix it:
- Use the project name as part of the FQN for dbt models so that
dbt_project_name.model_nameis the FQN that will be referenced in SQLMesh. It's predictable and stable but "inconsistent" with SQLMesh approach that expectsmy_schema.model_name. - Provide a variable in SQLMesh config from dbt integration to define the schema used for the FQN in SQLMesh: it could be used only for the FQN or it could also override the schema being used for all models?
- Ignore dbt usual schema name resolution (both macros and profiles.yml one) and use only the schema defined at dbt model level + configuration level one
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
