Skip to content

Commit

Permalink
Fix cardinality test error (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Labes authored and clrcrl committed May 18, 2021
1 parent bb21058 commit 49b56a3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
## Fixes
* Handle booleans gracefully in the unpivot macro ([#305](https://github.com/fishtown-analytics/dbt-utils/pull/305) [@avishalom](https://github.com/avishalom))
* Fix a bug in `get_relation_by_prefix` that happens with Snowflake external tables. Now the macro will retrieve tables that match the prefix which are external tables ([#350](https://github.com/fishtown-analytics/dbt-utils/issues/350))
* Fix `cardinality_equality` test when the two tables' column names differed ([#334](https://github.com/fishtown-analytics/dbt-utils/pull/334)) [@joellabes](https://github.com/joellabes)

## Under the hood


# dbt-utils v0.6.4

### Fixes
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
same_name
1
2
3
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
same_name,different_name
1,2
2,3
3,1
13 changes: 13 additions & 0 deletions integration_tests/models/schema_tests/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,18 @@ models:
combination_of_columns:
- month
- product

- name: data_cardinality_equality_a
columns:
- name: same_name
tests:
- dbt_utils.cardinality_equality:
to: ref('data_cardinality_equality_b')
field: same_name
- dbt_utils.cardinality_equality:
to: ref('data_cardinality_equality_b')
field: different_name


- name: data_test_accepted_range
columns:
Expand All @@ -145,3 +157,4 @@ models:
min_value: 0
inclusive: true
where: "id <> -1"

2 changes: 1 addition & 1 deletion macros/schema_tests/cardinality_equality.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ select
{{ field }},
count(*) as num_rows
from {{ to }}
group by {{ column_name }}
group by {{ field }}
),

except_a as (
Expand Down

0 comments on commit 49b56a3

Please sign in to comment.