Skip to content

Commit

Permalink
Fix partial aggregation skipping with Decimal aggregators (#11833)
Browse files Browse the repository at this point in the history
* Fix partial aggregation skipping for Decimal

* fix bug
  • Loading branch information
alamb authored Aug 6, 2024
1 parent d8bc7e2 commit 1c98e6e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ where
"initial_values underlying buffer must not be shared"
)
})?
.map_err(DataFusionError::from)?;
.map_err(DataFusionError::from)?
.with_data_type(self.data_type.clone());

Ok(vec![Arc::new(state_values)])
}
Expand Down
26 changes: 26 additions & 0 deletions datafusion/sqllogictest/test_files/aggregate_skip_partial.slt
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,29 @@ FROM aggregate_test_100_null GROUP BY c2 ORDER BY c2;
3 109 211 2.80575042963 2.80632930994
4 -171 56 2.10740506649 1.939846396446
5 -86 -76 1.8741710186 1.600569307804


statement ok
DROP TABLE aggregate_test_100_null;

# Test for aggregate functions with different intermediate types
# Need more than 10 values to trigger skipping
statement ok
CREATE TABLE decimal_table(i int, d decimal(10,3)) as
VALUES (1, 1.1), (2, 2.2), (3, 3.3), (2, 4.4), (1, 5.5);

statement ok
CREATE TABLE t(id int) as values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);

query IR
SELECT i, sum(d)
FROM decimal_table CROSS JOIN t
GROUP BY i
ORDER BY i;
----
1 66
2 66
3 33

statement ok
DROP TABLE decimal_table;

0 comments on commit 1c98e6e

Please sign in to comment.