This is an automated email from the ASF dual-hosted git repository.

dheres pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new 1c98e6e640 Fix partial aggregation skipping with Decimal aggregators 
(#11833)
1c98e6e640 is described below

commit 1c98e6e640090600d36ce51f87919fea7b6eeed2
Author: Andrew Lamb <[email protected]>
AuthorDate: Tue Aug 6 03:22:52 2024 -0400

    Fix partial aggregation skipping with Decimal aggregators (#11833)
    
    * Fix partial aggregation skipping for Decimal
    
    * fix bug
---
 .../src/aggregate/groups_accumulator/prim_op.rs    |  3 ++-
 .../test_files/aggregate_skip_partial.slt          | 26 ++++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git 
a/datafusion/physical-expr-common/src/aggregate/groups_accumulator/prim_op.rs 
b/datafusion/physical-expr-common/src/aggregate/groups_accumulator/prim_op.rs
index 8d69646bd4..acf1ae525c 100644
--- 
a/datafusion/physical-expr-common/src/aggregate/groups_accumulator/prim_op.rs
+++ 
b/datafusion/physical-expr-common/src/aggregate/groups_accumulator/prim_op.rs
@@ -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)])
     }
diff --git a/datafusion/sqllogictest/test_files/aggregate_skip_partial.slt 
b/datafusion/sqllogictest/test_files/aggregate_skip_partial.slt
index 65efc24ec0..6c0cf5f800 100644
--- a/datafusion/sqllogictest/test_files/aggregate_skip_partial.slt
+++ b/datafusion/sqllogictest/test_files/aggregate_skip_partial.slt
@@ -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;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to