martin-g commented on code in PR #20504:
URL: https://github.com/apache/datafusion/pull/20504#discussion_r2849555974


##########
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:
   Let's see what others think.
   My opinion is that a library should try to avoid panicking as hard as 
possible.
   But this could be improved in a follow-up if others agree!



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