-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add expect_column_distinct_count_to_equal_other_table (#50)
- Loading branch information
1 parent
9131e47
commit f100088
Showing
3 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...os/schema_tests/aggregate_functions/expect_column_distinct_count_to_equal_other_table.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{% macro test_expect_column_distinct_count_to_equal_other_table(model, | ||
compare_model, | ||
column_name, | ||
compare_column_name, | ||
row_condition=None, | ||
compare_row_condition=None | ||
) %} | ||
{%- set expression -%} | ||
count(distinct {{ column_name }}) | ||
{%- endset -%} | ||
{%- set compare_expression -%} | ||
{%- if compare_column_name -%} | ||
count(distinct {{ compare_column_name }}) | ||
{%- else -%} | ||
{{ expression }} | ||
{%- endif -%} | ||
{%- endset -%} | ||
{{ dbt_expectations.test_equal_expression( | ||
model, | ||
expression=expression, | ||
compare_model=compare_model, | ||
compare_expression=compare_expression, | ||
row_condition=row_condition, | ||
compare_row_condition=compare_row_condition, | ||
return_difference=True | ||
) }} | ||
{%- endmacro -%} |