alamb commented on a change in pull request #1681:
URL: https://github.com/apache/arrow-datafusion/pull/1681#discussion_r792940671



##########
File path: datafusion/src/physical_plan/expressions/array_agg.rs
##########
@@ -95,77 +95,60 @@ impl AggregateExpr for ArrayAgg {
 
 #[derive(Debug)]
 pub(crate) struct ArrayAggAccumulator {
-    array: Vec<ScalarValue>,
+    values: Vec<ScalarValue>,
     datatype: DataType,
 }
 
 impl ArrayAggAccumulator {
     /// new array_agg accumulator based on given item data type
     pub fn try_new(datatype: &DataType) -> Result<Self> {
         Ok(Self {
-            array: vec![],
+            values: vec![],
             datatype: datatype.clone(),
         })
     }
-
-    fn update(&mut self, values: &[ScalarValue]) -> Result<()> {
-        let value = &values[0];
-        self.array.push(value.clone());
-
-        Ok(())
-    }
-
-    fn merge(&mut self, states: &[ScalarValue]) -> Result<()> {
-        if states.is_empty() {
-            return Ok(());
-        };
-
-        assert!(states.len() == 1, "states length should be 1!");
-        match &states[0] {
-            ScalarValue::List(Some(array), _) => {
-                self.array.extend((&**array).clone());
-            }
-            _ => unreachable!(),
-        }
-        Ok(())
-    }
 }
 
 impl Accumulator for ArrayAggAccumulator {
     fn update_batch(&mut self, values: &[ArrayRef]) -> Result<()> {
         if values.is_empty() {
             return Ok(());
         };
-        (0..values[0].len()).try_for_each(|index| {
-            let v = values
-                .iter()
-                .map(|array| ScalarValue::try_from_array(array, index))
-                .collect::<Result<Vec<_>>>()?;
-            self.update(&v)
+        assert!(values.len() == 1, "array_agg can only take 1 param!");

Review comment:
       I like the new assert 👍 




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