Skip to content

Commit

Permalink
Add built-in unique test if no preexisting test matches its name.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pfitzn authored and PatFitzner committed Sep 25, 2024
1 parent fcebd68 commit f066a8d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions models/marts/core/int_all_graph_resources.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

{# flatten the sets of permissable primary key test sets to one level for later iteration #}
{%- set test_macro_list = [] %}
{%- set test_macro_names_list = [] %}
{%- for test_set in var('primary_key_test_macros') -%}
{%- for test in test_set %}
{%- do test_macro_list.append(test) -%}
{%- do test_macro_list.append(test) -%}
{%- endfor %}
{%- endfor -%}
{%- if test_macro_list | length == 0 -%}
{% for test in test_macro_list %}
{%- do test_macro_names_list.append(test.split('.')[1]) -%}
{%- endfor -%}
{%- if "test_unique" not in test_macro_names_list -%}
{%- do test_macro_list.append("dbt.test_unique") -%}
{%- endif -%}
{%- set test_macro_set = set_strict(test_macro_list) -%}
Expand Down

0 comments on commit f066a8d

Please sign in to comment.