Skip to content

Commit

Permalink
Fix cardinality test error (#334)
Browse files Browse the repository at this point in the history
* group by field, not column_name

* Add integration tests and update changelog

* Forgot the refs on integration tests

* Provide package names in integration tests

Co-authored-by: Claire Carroll <[email protected]>
  • Loading branch information
Joel Labes and Claire Carroll authored Apr 16, 2021
1 parent 7c6de17 commit 56ef1d2
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 @@ -51,7 +51,7 @@ If you were relying on the position to match up your optional arguments, this ma
## 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)

# dbt-utils v0.6.4

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 56ef1d2

Please sign in to comment.