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


##########
datafusion/physical-expr/src/aggregate/sum.rs:
##########
@@ -319,11 +392,34 @@ impl Accumulator for SumAccumulator {
     fn evaluate(&self) -> Result<ScalarValue> {
         // TODO: add the checker for overflow
         // For the decimal(precision,_) data type, the absolute of value must 
be less than 10^precision.
-        Ok(self.sum.clone())
+
+        match &self.sum {
+            ColumnarValue::Scalar(sv) => Ok(sv.clone()),
+            ColumnarValue::Array(_) => Err(DataFusionError::Internal(format!(
+                "Sum is not expected to receive the type {:?}",
+                self.sum.data_type()
+            ))),
+        }
+    }
+
+    fn evaluate_v2(&self) -> Result<ColumnarValue> {
+        // TODO: add the checker for overflow
+        // For the decimal(precision,_) data type, the absolute of value must 
be less than 10^precision.
+
+        match &self.sum {
+            ColumnarValue::Scalar(sv) => Ok(self.sum.clone()),
+            ColumnarValue::Array(ref array) => Ok(self.sum.clone()),
+        }
     }
 
     fn size(&self) -> usize {
-        std::mem::size_of_val(self) - std::mem::size_of_val(&self.sum) + 
self.sum.size()
+        match self.sum {
+            ColumnarValue::Scalar(ref sv) => {
+                std::mem::size_of_val(self) - std::mem::size_of_val(sv) + 
sv.size()
+            }
+            // TODO: Return Correct value
+            ColumnarValue::Array(ref array) => 0,

Review Comment:
   Not sure how to get the size of `array: ArrayRef`



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