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

bug in at_least_one test code logic #838

Closed
1 of 5 tasks
tffragoso opened this issue Sep 24, 2023 · 3 comments · Fixed by #922
Closed
1 of 5 tasks

bug in at_least_one test code logic #838

tffragoso opened this issue Sep 24, 2023 · 3 comments · Fixed by #922
Labels
bug Something isn't working

Comments

@tffragoso
Copy link

tffragoso commented Sep 24, 2023

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.

@tffragoso tffragoso added bug Something isn't working triage labels Sep 24, 2023
@basdunn
Copy link

basdunn commented Sep 27, 2023

We are also experiencing this issue with the at_least tests, preventing us from upgrading to 1.1.1.

Copy link

This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days.

@github-actions github-actions bot added the Stale label Mar 26, 2024
@tffragoso
Copy link
Author

Still a valid issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants