Skip to content

Commit

Permalink
Fix panic in variance GroupsAccumulator (#12615)
Browse files Browse the repository at this point in the history
The bug was in the orginal implementation in #12095. This fixes the
issue and modify a test case such that it would have caught it.
  • Loading branch information
eejbyfeldt authored Sep 25, 2024
1 parent b821929 commit 61e6db3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion datafusion/functions-aggregate/src/variance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ impl VarianceGroupsAccumulator {

if let StatsType::Sample = self.stats_type {
counts.iter_mut().for_each(|count| {
*count -= 1;
*count = count.saturating_sub(1);
});
}
let nulls = NullBuffer::from_iter(counts.iter().map(|&count| count != 0));
Expand Down
8 changes: 4 additions & 4 deletions datafusion/sqllogictest/test_files/aggregate.slt
Original file line number Diff line number Diff line change
Expand Up @@ -567,13 +567,13 @@ set datafusion.sql_parser.dialect = 'Postgres';

# csv_query_stddev_12
query IR
SELECT c2, var_samp(c12) FILTER (WHERE c12 > 0.90) FROM aggregate_test_100 GROUP BY c2 ORDER BY c2
SELECT c2, var_samp(c12) FILTER (WHERE c12 > 0.95) FROM aggregate_test_100 GROUP BY c2 ORDER BY c2
----
1 0.000889240174
2 0.000785878272
1 0.000791243479
2 0.000061521903
3 NULL
4 NULL
5 0.000269544643
5 NULL

# Restore the default dialect
statement ok
Expand Down

0 comments on commit 61e6db3

Please sign in to comment.