mustafasrepo commented on issue #4943:
URL: 
https://github.com/apache/arrow-datafusion/issues/4943#issuecomment-1385360298

   I think the reason is that UnionExec doesn't implement `fn 
maintains_input_order(&self) -> bool`. But sometimes it maintains_input_order. 
If we implement `fn maintains_input_order(&self) -> bool` as below (Taken from 
`output_ordering` implementation). I think the problem will be solved. 
   ``` rust
   fn maintains_input_order(&self) -> bool {
       let first_input_ordering = self.inputs[0].output_ordering();
       // If the Union is not partition aware and all the input ordering spec 
strictly equal with the first_input_ordering
       // `UnionExec` maintains input order
       //
       // It might be too strict here in the case that the input ordering are 
compatible but not exactly the same.
       // For example one input ordering has the ordering spec 
SortExpr('a','b','c') and the other has the ordering
       // spec SortExpr('a'), It is safe to derive the out ordering with the 
spec SortExpr('a').
       !self.partition_aware
           && first_input_ordering.is_some()
           && self
           .inputs
           .iter()
           .map(|plan| plan.output_ordering())
           .all(|ordering| {
               ordering.is_some()
                   && sort_expr_list_eq_strict_order(
                   ordering.unwrap(),
                   first_input_ordering.unwrap(),
               )
           })
   }
   ```


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