Skip to content

Commit 49b56a3

Browse files
Joel Labesclrcrl
Joel Labes
authored andcommitted
Fix cardinality test error (#334)
1 parent bb21058 commit 49b56a3

File tree

5 files changed

+23
-2
lines changed

5 files changed

+23
-2
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
## Fixes
1212
* Handle booleans gracefully in the unpivot macro ([#305](https://github.com/fishtown-analytics/dbt-utils/pull/305) [@avishalom](https://github.com/avishalom))
1313
* 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))
14+
* 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)
1415

1516
## Under the hood
1617

17-
1818
# dbt-utils v0.6.4
1919

2020
### Fixes
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
same_name
2+
1
3+
2
4+
3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
same_name,different_name
2+
1,2
3+
2,3
4+
3,1

integration_tests/models/schema_tests/schema.yml

+13
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,18 @@ models:
126126
combination_of_columns:
127127
- month
128128
- product
129+
130+
- name: data_cardinality_equality_a
131+
columns:
132+
- name: same_name
133+
tests:
134+
- dbt_utils.cardinality_equality:
135+
to: ref('data_cardinality_equality_b')
136+
field: same_name
137+
- dbt_utils.cardinality_equality:
138+
to: ref('data_cardinality_equality_b')
139+
field: different_name
140+
129141

130142
- name: data_test_accepted_range
131143
columns:
@@ -145,3 +157,4 @@ models:
145157
min_value: 0
146158
inclusive: true
147159
where: "id <> -1"
160+

macros/schema_tests/cardinality_equality.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ select
2525
{{ field }},
2626
count(*) as num_rows
2727
from {{ to }}
28-
group by {{ column_name }}
28+
group by {{ field }}
2929
),
3030

3131
except_a as (

0 commit comments

Comments
 (0)