Skip to content

Commit 1c98e6e

Browse files
authored
Fix partial aggregation skipping with Decimal aggregators (#11833)
* Fix partial aggregation skipping for Decimal * fix bug
1 parent d8bc7e2 commit 1c98e6e

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

datafusion/physical-expr-common/src/aggregate/groups_accumulator/prim_op.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ where
184184
"initial_values underlying buffer must not be shared"
185185
)
186186
})?
187-
.map_err(DataFusionError::from)?;
187+
.map_err(DataFusionError::from)?
188+
.with_data_type(self.data_type.clone());
188189

189190
Ok(vec![Arc::new(state_values)])
190191
}

datafusion/sqllogictest/test_files/aggregate_skip_partial.slt

+26
Original file line numberDiff line numberDiff line change
@@ -322,3 +322,29 @@ FROM aggregate_test_100_null GROUP BY c2 ORDER BY c2;
322322
3 109 211 2.80575042963 2.80632930994
323323
4 -171 56 2.10740506649 1.939846396446
324324
5 -86 -76 1.8741710186 1.600569307804
325+
326+
327+
statement ok
328+
DROP TABLE aggregate_test_100_null;
329+
330+
# Test for aggregate functions with different intermediate types
331+
# Need more than 10 values to trigger skipping
332+
statement ok
333+
CREATE TABLE decimal_table(i int, d decimal(10,3)) as
334+
VALUES (1, 1.1), (2, 2.2), (3, 3.3), (2, 4.4), (1, 5.5);
335+
336+
statement ok
337+
CREATE TABLE t(id int) as values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
338+
339+
query IR
340+
SELECT i, sum(d)
341+
FROM decimal_table CROSS JOIN t
342+
GROUP BY i
343+
ORDER BY i;
344+
----
345+
1 66
346+
2 66
347+
3 33
348+
349+
statement ok
350+
DROP TABLE decimal_table;

0 commit comments

Comments
 (0)