dbt_constraints icon indicating copy to clipboard operation
dbt_constraints copied to clipboard

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

Open mjahammel opened this issue 2 years ago • 3 comments

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.

mjahammel avatar Feb 07 '23 20:02 mjahammel

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

erikwilkins-doosan avatar Aug 31 '23 15:08 erikwilkins-doosan

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.

drewblinn avatar Mar 14 '24 18:03 drewblinn

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.

sfc-gh-dflippo avatar Jul 25 '24 22:07 sfc-gh-dflippo