From 464ae0b59544ea26668b3bfd430c6df9f3745ca2 Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Tue, 28 Mar 2023 17:40:09 -0500 Subject: [PATCH] update to retrieve contract enforced from dict (#383) * update to retrieve contract enforced from dict * add dependecy on branch * change ref * Update Under the Hood-20230223-110314.yaml * remove extra get * revert branch dependency --- .changes/1.5.0/Under the Hood-20230223-110314.yaml | 6 ------ .changes/unreleased/Under the Hood-20230223-110314.yaml | 6 ++++++ dbt/include/redshift/macros/adapters.sql | 6 ++++-- 3 files changed, 10 insertions(+), 8 deletions(-) delete mode 100644 .changes/1.5.0/Under the Hood-20230223-110314.yaml create mode 100644 .changes/unreleased/Under the Hood-20230223-110314.yaml diff --git a/.changes/1.5.0/Under the Hood-20230223-110314.yaml b/.changes/1.5.0/Under the Hood-20230223-110314.yaml deleted file mode 100644 index ef1e35744..000000000 --- a/.changes/1.5.0/Under the Hood-20230223-110314.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Under the Hood -body: Rename constraints_enabled to contract -time: 2023-02-23T11:03:14.344028-05:00 -custom: - Author: gshank - Issue: "330" diff --git a/.changes/unreleased/Under the Hood-20230223-110314.yaml b/.changes/unreleased/Under the Hood-20230223-110314.yaml new file mode 100644 index 000000000..a4f519569 --- /dev/null +++ b/.changes/unreleased/Under the Hood-20230223-110314.yaml @@ -0,0 +1,6 @@ +kind: Under the Hood +body: Treat contract config as a python object +time: 2023-02-23T11:03:14.344028-05:00 +custom: + Author: gshank emmyoop + Issue: 330 382 diff --git a/dbt/include/redshift/macros/adapters.sql b/dbt/include/redshift/macros/adapters.sql index ebf2e16a5..c863ee362 100644 --- a/dbt/include/redshift/macros/adapters.sql +++ b/dbt/include/redshift/macros/adapters.sql @@ -43,7 +43,8 @@ {{ sql_header if sql_header is not none }} - {%- if config.get('contract', False) %} + {%- set contract_config = config.get('contract') -%} + {%- if contract_config.enforced -%} create {% if temporary -%}temporary{%- endif %} table {{ relation.include(database=(not temporary), schema=(not temporary)) }} @@ -85,7 +86,8 @@ {{ sql_header if sql_header is not none }} create view {{ relation }} - {% if config.get('contract', False) -%} + {%- set contract_config = config.get('contract') -%} + {%- if contract_config.enforced -%} {{ get_assert_columns_equivalent(sql) }} {%- endif %} as ( {{ sql }}