From 4ba048ec2819f3ac6568cd6b4754f5bd92cd6bba Mon Sep 17 00:00:00 2001 From: Joel Labes Date: Wed, 10 Feb 2021 16:38:34 +1300 Subject: [PATCH 1/4] group by field, not column_name --- macros/schema_tests/cardinality_equality.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macros/schema_tests/cardinality_equality.sql b/macros/schema_tests/cardinality_equality.sql index 3879c317..c6923685 100644 --- a/macros/schema_tests/cardinality_equality.sql +++ b/macros/schema_tests/cardinality_equality.sql @@ -25,7 +25,7 @@ select {{ field }}, count(*) as num_rows from {{ to }} -group by {{ column_name }} +group by {{ field }} ), except_a as ( From 427aa45c569b02a0b5c49f169817e02e1c4b6668 Mon Sep 17 00:00:00 2001 From: Joel Labes Date: Wed, 10 Feb 2021 16:54:48 +1300 Subject: [PATCH 2/4] Add integration tests and update changelog --- CHANGELOG.md | 4 ++++ .../schema_tests/data_cardinality_equality_a.csv | 4 ++++ .../schema_tests/data_cardinality_equality_b.csv | 4 ++++ integration_tests/models/schema_tests/schema.yml | 13 +++++++++++++ 4 files changed, 25 insertions(+) create mode 100644 integration_tests/data/schema_tests/data_cardinality_equality_a.csv create mode 100644 integration_tests/data/schema_tests/data_cardinality_equality_b.csv diff --git a/CHANGELOG.md b/CHANGELOG.md index 7392496e..de504b14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# dbt-utils v0.6.5 +### Fixes +- 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 ### Fixes diff --git a/integration_tests/data/schema_tests/data_cardinality_equality_a.csv b/integration_tests/data/schema_tests/data_cardinality_equality_a.csv new file mode 100644 index 00000000..ad9cdeb5 --- /dev/null +++ b/integration_tests/data/schema_tests/data_cardinality_equality_a.csv @@ -0,0 +1,4 @@ +same_name +1 +2 +3 \ No newline at end of file diff --git a/integration_tests/data/schema_tests/data_cardinality_equality_b.csv b/integration_tests/data/schema_tests/data_cardinality_equality_b.csv new file mode 100644 index 00000000..dfca57d6 --- /dev/null +++ b/integration_tests/data/schema_tests/data_cardinality_equality_b.csv @@ -0,0 +1,4 @@ +same_name,different_name +1,2 +2,3 +3,1 \ No newline at end of file diff --git a/integration_tests/models/schema_tests/schema.yml b/integration_tests/models/schema_tests/schema.yml index 55de5a68..7f7ac1b2 100644 --- a/integration_tests/models/schema_tests/schema.yml +++ b/integration_tests/models/schema_tests/schema.yml @@ -101,3 +101,16 @@ models: combination_of_columns: - month - product + + + - name: data_cardinality_equality_a + columns: + - name: same_name + tests: + - cardinality_equality: + to: data_cardinality_equality_b + field: same_name + - cardinality_equality: + to: data_cardinality_equality_b + field: different_name + \ No newline at end of file From d9e798665d9fefa76add988144ddbb0ce709b342 Mon Sep 17 00:00:00 2001 From: Joel Labes Date: Wed, 10 Feb 2021 17:06:07 +1300 Subject: [PATCH 3/4] Forgot the refs on integration tests --- integration_tests/models/schema_tests/schema.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration_tests/models/schema_tests/schema.yml b/integration_tests/models/schema_tests/schema.yml index 7f7ac1b2..ce016517 100644 --- a/integration_tests/models/schema_tests/schema.yml +++ b/integration_tests/models/schema_tests/schema.yml @@ -108,9 +108,9 @@ models: - name: same_name tests: - cardinality_equality: - to: data_cardinality_equality_b + to: ref('data_cardinality_equality_b') field: same_name - cardinality_equality: - to: data_cardinality_equality_b + to: ref('data_cardinality_equality_b') field: different_name \ No newline at end of file From 25308c6c24c74665d6fe104473a67290cffbf8a6 Mon Sep 17 00:00:00 2001 From: Joel Labes Date: Wed, 24 Feb 2021 16:20:47 +1300 Subject: [PATCH 4/4] Provide package names in integration tests --- integration_tests/models/schema_tests/schema.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration_tests/models/schema_tests/schema.yml b/integration_tests/models/schema_tests/schema.yml index ce016517..06a40e54 100644 --- a/integration_tests/models/schema_tests/schema.yml +++ b/integration_tests/models/schema_tests/schema.yml @@ -107,10 +107,10 @@ models: columns: - name: same_name tests: - - cardinality_equality: + - dbt_utils.cardinality_equality: to: ref('data_cardinality_equality_b') field: same_name - - cardinality_equality: + - dbt_utils.cardinality_equality: to: ref('data_cardinality_equality_b') field: different_name \ No newline at end of file