-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: RANGE frame for corner cases with empty ORDER BY clause should be treated as constant sort #8445
Conversation
…e treated as constant sort
// Note that this follows Postgres behavior. | ||
// In these cases, we regularize the ORDER BY clause if the ORDER BY clause | ||
// is absent. If an ORDER BY clause is present but has more than one column, | ||
// the ORDER BY clause is unchanged. Note that this follows Postgres behavior. | ||
if (frame.start_bound.is_unbounded() | ||
|| frame.start_bound == WindowFrameBound::CurrentRow) | ||
&& (frame.end_bound == WindowFrameBound::CurrentRow | ||
|| frame.end_bound.is_unbounded()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RANGE frame with UNBOUNDED or CURRENT ROW PRECEDING/FOLLOWING without ORDER BY
, all rows of the partitions become peers of the current row, i.e., the sort expression returns the same for all rows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR @viirya. It is LGTM!.
Thank you @mustafasrepo |
…e treated as constant sort (apache#8445) * fix: RANGE frame for corner cases with empty ORDER BY clause should be treated as constant sort * fix * Make the test not flaky * fix clippy
Which issue does this PR close?
Closes #.
Rationale for this change
We currently regularize RANGE window frame with UNBOUNDED/CURRENT ROW bounds with empty ORDER BY clause to ROWS frame with the UNBOUNDED bounds. This produces inconsistent result compared to Postgres where the case is treated as ORDER BY with constant sort key and unchanged window frame.
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?