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.
Currently
sqlserver_adapterdoes not generate constraints, except for thenot nullconstraint if it is defined as a column constraint.The reason, as far as I understand this adapter is:
sqlserver_adapter.pyimplements therender_model_constraintmethod but not therender_column_constraintmethod. Whenrender_column_constraintis invoked the method implemented from the inheritedfabric_adapterclass is invoked which in turn only supports thenot nullconstraint, all other column constraints are ignored.dbt/include/sqlserver/macros/materializations/models//table/table.sqis missing a{{ build_model_constraints(target_relation) }}tag that is present in thefabrictemplate and therefore therender_model_constraintmethod is never invoked, neither insqlserver_adapternor 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.