dbt Constraints v0.6.1
What's Changed
- Add support for Vertica database by @jaceksan in #50
- Added
match simple
to Snowflake DDL to avoid errors on FK from nullable columns by @sfc-gh-dflippo in #54 - Added always_create_constraint config option by @sfc-gh-dflippo in #56
The always_create_constraint feature should address several open feature requests. Until now there was no way to force a constraint to be generated when there was a where
configuration or if the constraint has a threshold. Now a always_create_constraint
configuration setting will override those exclusions.
PLEASE NOTE:
- You will get an error if you try to force constraints that are enforced by your database. On Snowflake that is only a not_null constraint but on databases like Oracle, all the generated constraints are enforced.
- This feature can all cause unexpected query results on Snowflake due to join elimination. Some users specifically requested that they could have the benefits of join elimination where there was a missing parent 0 or -1 record. Personally, I would force the parent to have a 0 or -1 record but I understand there are scenarios for data vault that would benefit from this feature.
This is an example from the integration tests using the feature:
- name: dim_duplicate_orders
description: "Test that we do not try to create PK/UK on failed tests"
columns:
- name: o_orderkey
description: "The primary key for this table"
- name: o_orderkey_seq
description: "duplicate seq column to test UK"
tests:
# This constraint should be skipped because it has failures
- dbt_constraints.primary_key:
column_name: o_orderkey
config:
severity: warn
# This constraint should be still generated because always_create_constraint=true
- dbt_constraints.unique_key:
column_name: o_orderkey
config:
warn_if: ">= 5000"
error_if: ">= 10000"
always_create_constraint: true
# This constraint should be still generated because always_create_constraint=true
- dbt_constraints.unique_key:
column_name: o_orderkey_seq
config:
severity: warn
always_create_constraint: true
New Contributors
Full Changelog: 0.6.0...0.6.1