You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: SortPreservingMerge sanity check rejects valid ORDER BY with CASE expression (#18342)
## Which issue does this PR close?
- Closes#18327
## Rationale for this change
ORDER BY with a CASE statement didn't always work, raising a sanity
check error in SortPreservingMergeExec. The plan showed that the
partitions all had the same ordering, but for whatever reason they were
not detected as being equal. Using a single partition succeeded always.
## What changes are included in this PR?
The changes are non-obvious and I spent a lot of time bisecting/debug
printing and landed on a failure in bounds checking with boolean
interval arithmetic. Returning UNCERTAIN if either leg of the interval
is NULL resolves the upstream issue where CASE statements end up being
deemed Unordered.
My rust-fu is hobbyist at best, so while this appears to resolve my
issue I cannot for-certain exclaim that I've solved it all (Claude 4.5
agrees with my fix, but that's not an indication its any good). I'm also
reasonably certain my unit tests are more ham fisted than necessary.
## Are these changes tested?
1. Yes, unit tests have been added.
## Are there any user-facing changes?
This does not change any behavior beyond resolving a bug with a valid
SQL statement.
---------
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
0 commit comments