wiedld opened a new pull request, #12414:
URL: https://github.com/apache/datafusion/pull/12414

   ## Which issue does this PR close?
   
   We have failures caused by SanityCheckPlan not considering the constants in 
the UnionExec input orderings. We made an exact reproducer in the [first 
commit's test 
case](https://github.com/apache/datafusion/commit/c2e652e48c82aedb20c289cbf5e7a7e279aa436e).
   
   ## Rationale for this change
   
   Given the following scenario:
   ```
   ParentWithSort [proj1 sorted, proj2 sorted]
        UnionExec
              InputWithSort [proj1 sorted] proj2 is constant
              InputWithSort [proj2 sorted] proj1 is constant
   ```
   
   The SanityCheckPlan was failing, because the UnionExec has the following 
orderings vs constants:
   ```
   oeq_class: OrderingEquivalenceClass { 
           orderings: [
               [proj1 sorted], 
               [proj2 sorted]
           ] 
       }, 
       constants: [], 
       ...
   }
   ```
   which means that no single ordering (minus constants) could fulfill the 
`[proj1 sorted, proj2 sorted]` sort requirement. Because the UnionExec has it's 
input orderings but not it's input constants.
   
   
   ## What changes are included in this PR?
   
   I elected to perform the comparisons (during the SanityPlanCheck) between 
the UnionExec's parent and children, skipping the union exec itself.
   
   Alternatively, I could have elected to:
   * modify the UnionExec's equivalence properties output ordering:
        * to make it `orderings: [[proj1 sorted, proj2-constant  sorted], 
[proj1-contant sorted, proj2 sorted]] 
        * But that adds constants to ordering. 🤔 
   * I wasn't going to add to the UnionExec's constants, since neither 
projections are constant across the entire union.
   
   
   ## Are these changes tested?
   
   Yes.
   
   ## Are there any user-facing changes?
   
   No.
   


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