Skip to content

Commit

Permalink
simplify logic
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno committed Dec 16, 2022
1 parent e1b7975 commit 4112453
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions macros/generic_tests/equality.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,19 @@ information schema — this allows the model to be an ephemeral model

{%- if not compare_columns -%}
{%- do dbt_utils._is_ephemeral(model, 'test_equality') -%}
{%- set compare_columns = adapter.get_columns_in_relation(model) | map(attribute='name') -%}
{%- set compare_columns = adapter.get_columns_in_relation(model) | map(attribute='name') | list -%}
{%- endif -%}

{%- if ignore_columns -%}
{#-- Lower case ignore columns for easier comparison --#}
{%- set ignore_columns = ignore_columns | map("lower") | list %}

{%- set include_columns = [] %}
{%- for column in compare_columns -%}
{%- if column | lower not in ignore_columns -%}
{% do include_columns.append(column) %}
{%- if column | lower in ignore_columns -%}
{% do compare_columns.remove(column) %}
{%- endif %}
{%- endfor %}

{%- set compare_columns = include_columns %}

{%- endif -%}

{% set compare_cols_csv = compare_columns | join(', ') %}
Expand Down

0 comments on commit 4112453

Please sign in to comment.