Skip to content

Commit

Permalink
Emergency fix for macro namespace references
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-dflippo committed Jul 26, 2024
1 parent 94cefff commit b3eab1b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

name: 'dbt_constraints'
version: '1.0.0'
version: '1.0.1'
config-version: 2

# These macros depend on the results and graph objects in dbt >=0.19.0
Expand Down
12 changes: 6 additions & 6 deletions macros/create_constraints.sql
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
{%- if test_model.unique_id in selected_resources -%}
{{ return("TEST_SELECTED") }}
{%- endif -%}
{%- if lists_intersect(test_model.depends_on.nodes, selected_resources) -%}
{%- if dbt_constraints.lists_intersect(test_model.depends_on.nodes, selected_resources) -%}
{{ return("MODEL_SELECTED") }}
{%- endif -%}

Expand All @@ -196,9 +196,9 @@
{%- for fk_model in graph.nodes.values() | selectattr("resource_type", "equalto", "test")
if fk_model.test_metadata
and fk_model.test_metadata.name in ("foreign_key", "relationships")
and lists_intersect(test_model.depends_on.nodes, fk_model.depends_on.nodes)
and dbt_constraints.lists_intersect(test_model.depends_on.nodes, fk_model.depends_on.nodes)
and ( fk_model.unique_id in selected_resources
or lists_intersect(fk_model.depends_on.nodes, selected_resources) ) -%}
or dbt_constraints.lists_intersect(fk_model.depends_on.nodes, selected_resources) ) -%}
{%- set fk_test_args = fk_model.test_metadata.kwargs -%}
{%- set fk_test_columns = [] -%}
{%- if fk_test_args.pk_column_names -%}
Expand Down Expand Up @@ -270,13 +270,13 @@

{%- set test_parameters = test_model.test_metadata.kwargs -%}
{%- set test_name = test_model.test_metadata.name -%}
{%- set selected = test_selected(test_model) -%}
{%- set selected = dbt_constraints.test_selected(test_model) -%}

{#- We can shortcut additional tests if the constraint was not selected -#}
{%- if selected is not none -%}
{#- rely_clause clause will be RELY if a test passed, NORELY if it failed, and '' if it was skipped -#}
{%- set rely_clause = lookup_should_rely(test_model) -%}
{%- set always_create_constraint = should_always_create_constraint(test_model) -%}
{%- set rely_clause = dbt_constraints.lookup_should_rely(test_model) -%}
{%- set always_create_constraint = dbt_constraints.should_always_create_constraint(test_model) -%}
{%- else -%}
{%- set rely_clause = '' -%}
{%- set always_create_constraint = false -%}
Expand Down
6 changes: 3 additions & 3 deletions macros/snowflake__create_constraints.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
{#- Check that the table does not already have this PK/UK -#}
{%- set existing_constraint = dbt_constraints.unique_constraint_exists(table_relation, column_names, lookup_cache) -%}
{%- if constraint_name == existing_constraint -%}
{%- do set_rely_norely(table_relation, constraint_name, lookup_cache.unique_keys[table_relation][constraint_name].rely, rely_clause) -%}
{%- do dbt_constraints.set_rely_norely(table_relation, constraint_name, lookup_cache.unique_keys[table_relation][constraint_name].rely, rely_clause) -%}
{%- do lookup_cache.unique_keys.update({table_relation: {constraint_name:
{ "constraint_name": constraint_name,
"columns": column_names,
Expand Down Expand Up @@ -63,7 +63,7 @@
{#- Check that the table does not already have this PK/UK -#}
{%- set existing_constraint = dbt_constraints.unique_constraint_exists(table_relation, column_names, lookup_cache) -%}
{%- if constraint_name == existing_constraint -%}
{%- do set_rely_norely(table_relation, constraint_name, lookup_cache.unique_keys[table_relation][constraint_name].rely, rely_clause) -%}
{%- do dbt_constraints.set_rely_norely(table_relation, constraint_name, lookup_cache.unique_keys[table_relation][constraint_name].rely, rely_clause) -%}
{%- do lookup_cache.unique_keys.update({table_relation: {constraint_name:
{ "constraint_name": constraint_name,
"columns": column_names,
Expand Down Expand Up @@ -107,7 +107,7 @@
{#- Check if the table already has this foreign key -#}
{%- set existing_constraint = dbt_constraints.foreign_key_exists(fk_table_relation, fk_column_names, lookup_cache) -%}
{%- if constraint_name == existing_constraint -%}
{%- do set_rely_norely(fk_table_relation, constraint_name, lookup_cache.foreign_keys[fk_table_relation][constraint_name].rely, rely_clause) -%}
{%- do dbt_constraints.set_rely_norely(fk_table_relation, constraint_name, lookup_cache.foreign_keys[fk_table_relation][constraint_name].rely, rely_clause) -%}
{%- do lookup_cache.foreign_keys.update({fk_table_relation: {constraint_name:
{"constraint_name": constraint_name,
"columns": fk_column_names,
Expand Down

0 comments on commit b3eab1b

Please sign in to comment.