yjshen commented on code in PR #2375:
URL: https://github.com/apache/arrow-datafusion/pull/2375#discussion_r866926702


##########
datafusion/physical-expr/src/aggregate/sum.rs:
##########
@@ -338,6 +455,42 @@ impl Accumulator for SumAccumulator {
     }
 }
 
+#[derive(Debug)]
+struct SumAccumulatorV2 {
+    index: usize,
+    datatype: DataType,
+}
+
+impl SumAccumulatorV2 {
+    pub fn new(index: usize, datatype: DataType) -> Self {
+        Self { index, datatype }
+    }
+}
+
+impl AccumulatorV2 for SumAccumulatorV2 {
+    fn update_batch(
+        &mut self,
+        values: &[ArrayRef],
+        accessor: &mut RowAccessor,
+    ) -> Result<()> {
+        let values = &values[0];
+        add_to_row(&self.datatype, self.index, accessor, &sum_batch(values)?)?;

Review Comment:
   I initially use `sum_batch` here mainly to reduce code duplication with that 
of `SumAccumulator`, besides, there's a decimal `sum_batch` that isn't included 
in the compute kernel yet.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to