Snowflake-Labs / dbt_constraints

This package generates database constraints based on the tests in a dbt project
Apache License 2.0
139 stars 27 forks source link

Allow specification of custom materialization types for pk/fk/uk constraints #43

Open mjahammel opened 1 year ago

mjahammel commented 1 year ago

The macro create_constraints_by_type contains a check for, among other things, the type of materialization (table, incremental, snapshot, and seed) when determining if the table resulting from a model will have constraints created for it. This prevents dbt_constraints from creating constraints on tables created by custom materialization types.

Please add the ability to specify additional materialization types for which constraints can be created (or remove the check entirely?).

Thanks.

erikwilkins-doosan commented 1 year ago

Is there any update on this? I am attempting to use dbt_constraints in combination with automate_dv's vault_insert_by_rank custom materialization

drewblinn commented 6 months ago

I was able to get around this by adding the name of my custom materialization to line 189 of the create_constraints macro.

Would be great if you could specify a list of custom materializations to include in this check via a variable.

sfc-gh-dflippo commented 1 month ago

This is one of the features addressed in Release 1.0.0. We now allow for custom materializations and just exclude views and ephemeral models. For custom materializations the logic will verify we have the correct privileges on the object, like we do for sources. Please let me know if this solves your issue.