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
{{ message }}
Repository navigation
Commit b07f96f
Browse filesBrowse the repository at this point in the historyBrowse files
fix: do not derive ordering for arithmetic that can overflow
Adding or subtracting two ordered columns was assumed to preserve
ordering, but the default wrapping arithmetic breaks monotonicity on
overflow (e.g. the sum of two ascending UInt8 columns wraps back to
small values), so eliding a SortExec based on the derived ordering
returns wrongly ordered results.
Keep the derived ordering for + / - only when overflow cannot corrupt
it: the expression errors on overflow instead of wrapping, the result
is a constant, or the result range proves overflow is impossible.
Closesapache#23902.
Co-Authored-By: Claude Fable 5 <[email protected]>
# Verify that the sort prefix is correctly computed over normalized, order-maintaining projections (number + 1, number, number + 1, age)
377
+
# `number + 1` is not order-maintaining (addition can overflow and wrap), so
378
+
# no sort prefix can be computed over the projected expression.
378
379
query TT
379
380
explain select number + 1 as number_plus, number, number + 1 as other_number_plus, age from partial_sorted order by number_plus desc, number desc, other_number_plus desc, age asc limit 3;
0 commit comments