alamb commented on code in PR #4651:
URL: https://github.com/apache/arrow-datafusion/pull/4651#discussion_r1050105881


##########
datafusion/core/src/physical_plan/aggregates/hash.rs:
##########
@@ -498,14 +502,26 @@ fn create_batch_from_map(
         }
     }
 
+    // make group states mutable
+    let (mut group_by_values_vec, mut accumulator_set_vec): (Vec<_>, Vec<_>) =
+        accumulators
+            .group_states
+            .into_iter()
+            .map(|group_state| {
+                (
+                    VecDeque::from(group_state.group_by_values.to_vec()),

Review Comment:
   🤔  maybe we could use a VecDeque always and could avoid this copy too 🤔 



##########
datafusion/core/src/physical_plan/aggregates/hash.rs:
##########
@@ -498,14 +502,26 @@ fn create_batch_from_map(
         }
     }
 
+    // make group states mutable
+    let (mut group_by_values_vec, mut accumulator_set_vec): (Vec<_>, Vec<_>) =
+        accumulators
+            .group_states
+            .into_iter()
+            .map(|group_state| {
+                (
+                    VecDeque::from(group_state.group_by_values.to_vec()),
+                    VecDeque::from(group_state.accumulator_set),
+                )
+            })
+            .unzip();
+
     // First, output all group by exprs
     let mut columns = (0..num_group_expr)
-        .map(|i| {
+        .map(|_| {
             ScalarValue::iter_to_array(
-                accumulators
-                    .group_states
-                    .iter()
-                    .map(|group_state| group_state.group_by_values[i].clone()),

Review Comment:
   👍  



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