not_constant may generate false positive if used with group_by_column
igor-lobanov-maersk opened this issue · 4 comments
Describe the bug
not_constant generic test would generate a false positive if used with group_by_column and there is only one row within a group
Steps to reproduce
Test model:
-- file test.sql
select 1 as a, 10 as b
union all
select 1 as a, 11 as b
union all
select 2 as a, 21 as b
Test schema.yml:
version: 2
models:
- name: test
columns:
- name: b
tests:
- dbt_utils.not_constant:
group_by_columns: ['a']
Run: dbt test -m test
Expected results
Test passes, because if there is only one value in the group, it does not break the constancy rule.
Actual results
Test fails.
Context
To explain what I'm doing and where this might be useful to others. I am flattening a nested array, and setting a flag if a given record is the first one. I wanted to add a test to make sure this logic always works, because I'm relying on this flag to be true exactly once for each id of the original record. In some cases there is only one element in the array, which gets the flag set to true correctly, but the test thinks it's wrong.
Screenshots and log output
Not sure what else would help.
System information
The contents of your packages.yml
file:
packages:
- package: dbt-labs/dbt_utils
version: 1.1.1
Which database are you using dbt with?
Dremio
The output of dbt --version
:
Core:
- installed: 1.5.8
- latest: 1.6.6 - 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:
- dremio: 1.5.0 - Up to date!
Are you interested in contributing the fix?
PR provided #849
Hi team,
There has been no response to this issue report despite me providing a PR to fix it. I was wondering if this repo is still maintained?