Closed elca-anh closed 3 months ago
This is a valid request that I do not have capacity to fix at the moment. I would be happy to provide feedback on a PR if you open one. Thanks 👍
Hello, I will do it as soon as I get some time to test it
To test the constraint naming in test_contraints_macros.py, I need the macro "local_md5" or to mock it (better). How can I do that?
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