mingmwang commented on code in PR #4878:
URL: https://github.com/apache/arrow-datafusion/pull/4878#discussion_r1069156078
##########
datafusion/core/src/physical_optimizer/dist_enforcement.rs:
##########
@@ -431,9 +431,22 @@ fn reorder_aggregate_keys(
None
};
if let Some(partial_agg) = new_partial_agg {
+ // Build new group expressions that correspond to the
schema of partial_agg
let mut new_group_exprs = vec![];
- for idx in positions.into_iter() {
- new_group_exprs.push(group_by.expr()[idx].clone());
+ for (idx, position) in positions.into_iter().enumerate() {
+ let (group_expr, name) =
group_by.expr()[position].clone();
+
+ // Update the index of columns so that they correspond
to the schema of partial_agg
+ // rather than input_schema.
+ let group_expr = if let Some(group_col) =
+ group_expr.as_any().downcast_ref::<Column>()
+ {
+ Arc::new(Column::new(group_col.name(), idx))
+ as Arc<dyn PhysicalExpr>
Review Comment:
Good catch!! It is a bug.
--
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]