jayzhan211 commented on code in PR #7242:
URL: https://github.com/apache/arrow-datafusion/pull/7242#discussion_r1369360626


##########
datafusion/physical-expr/src/aggregate/sum.rs:
##########
@@ -191,12 +196,35 @@ impl<T: ArrowNumericType> Accumulator for 
SumAccumulator<T> {
         Ok(vec![self.evaluate()?])
     }
 
+    // There are two kinds of input, PrimitiveArray and ListArray
+    // ListArray is for multiple-rows input, and PrimitiveArray is for 
single-row input
     fn update_batch(&mut self, values: &[ArrayRef]) -> Result<()> {
-        let values = values[0].as_primitive::<T>();
-        if let Some(x) = sum(values) {
-            let v = self.sum.get_or_insert(T::Native::usize_as(0));
-            *v = v.add_wrapping(x);
+        // Wrap single-row input into multiple-rows input and use the same 
logic as multiple-rows input
+        let list_values = match as_list_array(&values[0]) {

Review Comment:
   I don't think I ignored the "error" here. I use the "error" of 
`as_list_array` to know whether it is List or non-List. 
   
   Btw, `Each error requires a string allocation`, can you elaborate more on 
why there is string allocation?



-- 
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