mingmwang commented on code in PR #4455:
URL: https://github.com/apache/arrow-datafusion/pull/4455#discussion_r1037113237


##########
datafusion/core/src/physical_plan/windows/window_agg_exec.rs:
##########
@@ -73,13 +77,43 @@ impl WindowAggExec {
     ) -> Result<Self> {
         let schema = create_schema(&input_schema, &window_expr)?;
         let schema = Arc::new(schema);
+        let window_expr_len = window_expr.len();
+        // Although WindowAggExec does not change the output ordering from the 
input, but can not return the output ordering
+        // from the input directly, need to adjust the column index to align 
with the new schema.
+        let output_ordering = input
+            .output_ordering()
+            .map(|sort_exprs| {
+                let new_sort_exprs: Result<Vec<PhysicalSortExpr>> = sort_exprs
+                    .iter()
+                    .map(|e| {
+                        let new_expr = e.expr.clone().transform_down(&|e| 
match e
+                            .as_any()
+                            .downcast_ref::<Column>()
+                        {
+                            Some(col) => Ok(Some(Arc::new(Column::new(
+                                col.name(),
+                                window_expr_len + col.index(),
+                            )))),
+                            None => Ok(None),
+                        });

Review Comment:
   Sure, I will follow your advice and change it.



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