-
Notifications
You must be signed in to change notification settings - Fork 607
Description
Describe the bug
From v1.1.0 to v1.1.1 there was a change to at_least_one test´s code.
I think this change actually broke the way the test should work. The bug is in the logic for pruned_rows CTE.
Steps to reproduce
Let´s look at a simple table, say demo_table:
| col_1 | col_2 |
+-------+-------+
| A | 10 |
+-------+-------+
| B | null |
+-------+-------+
If we were to configure the at_least_one test for this table, using group_by_columns parameter, we would have the following:
select_gb_cols = 'col_1'
groupby_gb_cols = 'group by col_1'
select_pruned_col = 'col_1, col_2'
Then, in pruned_rows CTE:
select
col_1, col_2
from demo_table
where col_2 is not null
limit 1
The output of this CTE would be:
| col_1 | col_2 |
+-------+-------+
| A | 10 |
+-------+-------+
Continuing following the test's code, the following piece of logic would now be applied:
select
col_1,
count(col_2) as filler_column
from pruned_rows
group by col_1
having count(col_2) = 0
The output would be empty, as our only record in pruned_rows does have a non-null value for col_2.
Expected results
I would expect this test to return the record with col_1=B, since for this value there are no non-null values in col_2.
Actual results
Explained above.
System information
dbt-labs/dbt_utils version 1.1.1
dbt version 1.6.3
bigquery plugin version 1.6.4
Which database are you using dbt with?
- postgres
- redshift
- bigquery
- snowflake
- other (specify: ____________)
Are you interested in contributing the fix?
Can definitely provide more context if needed, but not interested in developing the code.