Repository navigation
[CALCITE-7864] RANGE window frames should handle NULL ORDER BY keys - #5337
Merged
mihaibudiu merged 1 commit intoOct 18, 2026
Merged
Conversation
mihaibudiu
reviewed
Oct 18, 2026
| for (String type : new String[] {"integer", "bigint"}) { | ||
| for (String nulls : new String[] {"first", "last"}) { | ||
| // Cover PRECEDING and FOLLOWING for both the lower and upper bounds. | ||
| cases.add( |
Contributor
There was a problem hiding this comment.
how did you validate these expected results?
Please add a comment explaining.
Contributor
Author
There was a problem hiding this comment.
Thanks for the review. I ran all 28 SQL cases against PostgreSQL 14.24 and confirmed that all 140 result rows match the expected results, ignoring row order while preserving duplicate NULL-key rows. I also added a comment documenting the verification method and PostgreSQL version in d6df043.
mihaibudiu
approved these changes
Oct 18, 2026
mihaibudiu
left a comment
Contributor
There was a problem hiding this comment.
You can squash the commits for merging.
Handle nullable ORDER BY keys in offset RANGE boundaries and add 28 regression cases. Verify expected results against PostgreSQL 14.24.
letian-jiang
force-pushed
the
codex/calcite-7864-range-null-order-key
branch
from
October 18, 2026 05:16
d6df043 to
c1916eb
Compare
Contributor
Author
|
Thanks for the review! I’ve squashed the commits into a single commit: c1916eb. |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Jira Link
CALCITE-7864
Changes Proposed
Fix a NullPointerException when evaluating RANGE window frames with offset bounds and NULL ORDER BY keys.
Guard boundary arithmetic for nullable keys and preserve NULL as the boundary search key. Explicitly box the non-NULL result to prevent implicit unboxing in the conditional expression.
For NULL keys, offset lower and upper bounds resolve to the first and last NULL peers, respectively. UNBOUNDED endpoints retain their partition-boundary behavior.
For example:
Previously, this query threw a NullPointerException. It now returns
(1, 10), (2, 30), (NULL, 300), (NULL, 300), ignoring row order.Add 28 parameterized regression cases covering INTEGER/BIGINT, NULLS FIRST/LAST, offsets at both frame endpoints, and combinations with CURRENT ROW and UNBOUNDED bounds.