microsoft / dbt-fabric

MIT License
79 stars 28 forks source link

Constraint Name should be optional and generate a unique name #186

Open bebemn opened 5 months ago

bebemn commented 5 months ago

The documentation for constraints in dbt specifies that the name property is optional. If the name is left out of the definition dbt-fabric throws the following exception.

Database Error in model model1 (models\gold\datamart1\dimensions\table1.sql)
Constraint name cannot be empty. Provide constraint name  - column column1_hk and run the project again.
compiled Code at target\run\project1\models\gold\datamart1\dimensions\table1.sql

This was more of a problem when Fabric Data Warehouse prohibited using the same constraint name on multiple objects. This limitation appears to have been removed, at least in regard to tables in different schemas. However, it does not follow the standard and users changing platforms may have issue with this.

prdpsvs commented 5 months ago

@bebemn, Yes, the limitation still exists within a schema. What would be a good default naming convention for a constraint? {object}{pk/fk/uk}{column name}?

And what standard are you referring to?