-
Notifications
You must be signed in to change notification settings - Fork 535
Description
Describe the bug
I would like to limit the rows compared in dbt_utils.equality test with a where clause.
Steps to reproduce
Create two models with the same set of columns. Configure equality test with where configuration - in this case a date limitation.
`
version: 2
models:
- name: model_v2
tests:- dbt_utils.equality:
compare_model: ref('model_v1')
where: "dt_date > DATE_ADD(current_date('Europe/Stockholm'), INTERVAL -1 DAY)"
`
- dbt_utils.equality:
Expected results
The equality test executed with the where clause added to both "model" and "compare_model".
Actual results
Compilation error
Screenshots and log output
Compilation Error in test dbt_utils_equality_model_v2_ref_model_v1_ (models/model_v2.yml)
11:48:56 Macro test_equality expected a Relation but received the value: (select * from project
.dataset
.model_v2
where dt_date > DATE_ADD(current_date('Europe/Stockholm'), INTERVAL -1 DAY)) dbt_subquery
11:48:56
11:48:56 > in macro _is_relation (macros/cross_db_utils/_is_relation.sql)
11:48:56 > called by macro default__test_equality (macros/generic_tests/equality.sql)
11:48:56 > called by macro test_equality (macros/generic_tests/equality.sql)
System information
The contents of your packages.yml
file:
packages:
- package: dbt-labs/dbt_utils
version: 0.8.6 - package: mjirv/dbt_datamocktool
version: 0.2.0
Which database are you using dbt with?
- postgres
- redshift
- bigquery
- snowflake
- other (specify: ____________)
The output of dbt --version
:
Core:
- installed: 1.1.1
- latest: 1.3.0 - Update available!
Your version of dbt-core is out of date!
You can find instructions for upgrading here:
https://docs.getdbt.com/docs/installation
Plugins:
- bigquery: 1.1.1 - Update available!
At least one plugin is out of date or incompatible with dbt-core.
You can find instructions for upgrading here:
https://docs.getdbt.com/docs/installation
Additional context
It seems the check not working is https://github.com/dbt-labs/dbt-utils/blob/main/macros/generic_tests/equality.sql#L23
My understanding of the check is to make sure of the later use of adapter.get_columns_in_relation will work.
My guess is that the most important part that the where config is added is in the CTEs named a and b.
Are you interested in contributing the fix?
Sure - would be great with some hints on where to start