You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently sqlserver_adapter does not generate constraints, except for the not null constraint if it is defined as a column constraint.
The reason, as far as I understand this adapter is:
sqlserver_adapter.py implements the render_model_constraintmethod but not the render_column_constraint method. When render_column_constraintis invoked the method implemented from the inherited fabric_adapterclass is invoked which in turn only supports the not null constraint, all other column constraints are ignored.
dbt/include/sqlserver/macros/materializations/models//table/table.sq is missing a {{ build_model_constraints(target_relation) }} tag that is present in the fabric template and therefore the render_model_constraint method is never invoked, neither in sqlserver_adapter nor in fabric_adapter.
I did a quick test to confirm that adding these missing parts can fix this issue, however, I do not really understand the functioning and structure of the adapter/jinja templating etc. and therefore cannot provide a fix.
The text was updated successfully, but these errors were encountered:
davikor
changed the title
[BUG] Column constraints (Primary Key, Foreign Keys, Checks, Unique) and Model constraints are not generated
[Bug] Column constraints (Primary Key, Foreign Keys, Checks, Unique) and Model constraints are not generated
Nov 13, 2024
Currently
sqlserver_adapter
does not generate constraints, except for thenot null
constraint if it is defined as a column constraint.The reason, as far as I understand this adapter is:
sqlserver_adapter.py
implements therender_model_constraint
method but not therender_column_constraint
method. Whenrender_column_constraint
is invoked the method implemented from the inheritedfabric_adapter
class is invoked which in turn only supports thenot null
constraint, all other column constraints are ignored.dbt/include/sqlserver/macros/materializations/models//table/table.sq
is missing a{{ build_model_constraints(target_relation) }}
tag that is present in thefabric
template and therefore therender_model_constraint
method is never invoked, neither insqlserver_adapter
nor infabric_adapter
.I did a quick test to confirm that adding these missing parts can fix this issue, however, I do not really understand the functioning and structure of the adapter/jinja templating etc. and therefore cannot provide a fix.
The text was updated successfully, but these errors were encountered: