Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cardinality test error #334

Merged
merged 5 commits into from
Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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