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
Incorrect join ordering properties can cause required sorts to be removed #25052
Joins can incorrectly append the other input's ordering to the maintained input's ordering.
With duplicate probe keys, matching rows from the other input repeat for each probe row. The combined ordering is therefore not guaranteed. This can cause the optimizer to remove required sorts, affecting ORDER BY, ORDER BY with LIMIT, and ranking window functions.
To Reproduce
SETdatafusion.optimizer.prefer_hash_join = false;
CREATETABLEjoin_leftASVALUES (1, 10), (1, 20);
CREATETABLEjoin_rightASVALUES (1, 100), (1, 200);
SELECTl.column1AS key, r.column2AS value
FROM join_left l
JOIN join_right r ONl.column1=r.column1ORDER BYl.column1, r.column2;
The join can emit:
key value
1 100
1 200
1 100
1 200
Although the key ordering is preserved, the output is not ordered by (key, value).
Expected behavior
Join output ordering properties should reflect the ordering actually guaranteed by the join. Required sorts should remain when the other input's ordering is not preserved.
Activity
lyne7-sc commentedon Sep 8, 2026
take
Hold the merge tree with a root ordering assertion (#340)