Auto-named constraints does not take into account for the model/table name #747
Labels
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
Describe the feature
Column constraints can be named explicitly or automatically in the YAML model documentation.
When done automatically, the name is created by hashing the name of the column. Since constraint name shall be unique per schema, this is far from ideal as multiple columns might have the same name.
Explicit naming is not magic either since there can be no expansion of the name. In our case, we use prefixes to have several versions of the models in the dev environment. Since there are no macros within the YAML we cannot use the prefix in the constraint name.
Current code in dbt-databricks\dbt\include\databricks\macros\relations\constraints.sql:107:
{% set name = constraint.get("name") %}
{% if not name and local_md5 %}
{{ exceptions.warn("Constraint of type " ~ type ~ " with no
name
provided. Generating hash instead.") }}{%- set name = local_md5 (column.get("name", "") ~ ";" ~ expression ~ ";") -%}
{% endif %}
Describe alternatives you've considered
Add the model name as part of the hash
Additional context
Constraint documentation on models within YAML file.
Who will this benefit?
Model documentation
Are you interested in contributing this feature?
Yes, I can contribute on the validation of this feature and other tests
The text was updated successfully, but these errors were encountered: