neilconway commented on code in PR #20504:
URL: https://github.com/apache/datafusion/pull/20504#discussion_r2848971311


##########
datafusion/functions-aggregate/src/array_agg.rs:
##########
@@ -414,6 +435,293 @@ impl Accumulator for ArrayAggAccumulator {
     }
 }
 
+#[derive(Debug)]
+struct ArrayAggGroupsAccumulator {
+    datatype: DataType,
+    ignore_nulls: bool,
+    /// Input batches received via `update_batch`.
+    batches: Vec<ArrayRef>,
+    /// Per-group list of `(batch_index, row_index)` pairs into `batches`.
+    indices: Vec<Vec<(u32, u32)>>,
+    /// Number of index entries referencing each batch.
+    batch_refcounts: Vec<u32>,
+    /// Per-group array chunks from `merge_batch`.
+    merged: Vec<Vec<ArrayRef>>,
+}
+
+impl ArrayAggGroupsAccumulator {
+    fn new(datatype: DataType, ignore_nulls: bool) -> Self {
+        Self {
+            datatype,
+            ignore_nulls,
+            batches: Vec::new(),
+            indices: Vec::new(),
+            batch_refcounts: Vec::new(),
+            merged: Vec::new(),
+        }
+    }
+}
+
+impl GroupsAccumulator for ArrayAggGroupsAccumulator {
+    /// Store references to each input batch and record per-group
+    /// `(batch_index, row_index)` pairs. Materialization is deferred
+    /// to `evaluate`, which minimizes the work done per-batch.
+    fn update_batch(
+        &mut self,
+        values: &[ArrayRef],
+        group_indices: &[usize],
+        opt_filter: Option<&BooleanArray>,
+        total_num_groups: usize,
+    ) -> Result<()> {
+        assert_eq!(values.len(), 1, "single argument to update_batch");

Review Comment:
   I was using `assert_eq!` because that is what a bunch of the other aggregate 
functions use, e.g.,:
   
   * 
https://github.com/apache/datafusion/blob/10a1d4ea1bcb22db4860306cc678526116e4724e/datafusion/functions-aggregate/src/median.rs#L360
   * 
https://github.com/apache/datafusion/blob/10a1d4ea1bcb22db4860306cc678526116e4724e/datafusion/functions-aggregate/src/median.rs#L385
   * 
https://github.com/apache/datafusion/blob/10a1d4ea1bcb22db4860306cc678526116e4724e/datafusion/functions-aggregate/src/median.rs#L488
   * 
https://github.com/apache/datafusion/blob/10a1d4ea1bcb22db4860306cc678526116e4724e/datafusion/functions-aggregate/src/variance.rs#L510
   * 
https://github.com/apache/datafusion/blob/10a1d4ea1bcb22db4860306cc678526116e4724e/datafusion/functions-aggregate/src/variance.rs#L536
   
   I don't have a strong preference but we should probably be consistent.



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


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

Reply via email to