alamb commented on issue #26762:
URL: https://github.com/apache/datafusion/issues/26762#issuecomment-6618592955

   I reproduced this and confirmed it is a regression, so I have marked this 
issue as such.
   
   Running the SQL from the description with `datafusion-cli -f repro.sql` 
against released binaries and current `main`:
   
   | Version | Result |
   |---|---|
   | 53.0.0 | works |
   | 53.1.0 | works |
   | 54.0.0 | works |
   | 54.1.0 | works |
   | 55.0.0 | fails with `SanityCheckPlan` |
   | 55.1.0 | fails with `SanityCheckPlan` |
   | `main` (181a87af61) | fails with `SanityCheckPlan` |
   
   I bisected between 54.1.0 and 55.0.0 (building `datafusion-cli` at each step 
and running the repro). The first bad commit is d185ed54cf, "Fix ordering for 
UNION ALL over heterogeneous constants" (#23528). Its parent, 620262ba99, plans 
the query fine. That PR changed how `add_sort_above` / 
`add_sort_above_with_distribution` prune constant expressions from the required 
sort, which matches the symptom here: the optimizer drops the sort because it 
treats `k` as constant, but the sanity checker does not agree.
   
   For the record, the `EnsureRequirements` rule named in the error (#21976, 
fb1c0f342f) is not the cause: the query works both at that commit and at its 
parent.
   


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