[SQL] Implement (partially) FIRST_VALUE and LAST_VALUE window aggregation functions#3924
Merged
mihaibudiu merged 1 commit intomainfrom Apr 23, 2025
Merged
[SQL] Implement (partially) FIRST_VALUE and LAST_VALUE window aggregation functions#3924mihaibudiu merged 1 commit intomainfrom
FIRST_VALUE and LAST_VALUE window aggregation functions#3924mihaibudiu merged 1 commit intomainfrom
Conversation
FIRST_VALUE and LAST_VALUE window aggregation functions
…tion functions Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
gz
approved these changes
Apr 23, 2025
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.
We support
FIRST_VALUEandLAST_VALUEonly if they are used with anUNLIMITED RANGE.This is still useful, because
FIRST_VALUEis generated by the Calcite decorrelator when decorrelating queries that contain(ORDER BY ... LIMIT 1). This enables us to support such queries.This partially fixes #3918.
Testing this has uncovered some bugs related to the sorting of
NULLvalues and the handling ofNULLS LASTandNULLS FIRST. Some tests were passing although they were incorrect, because they were tested on a system whereNULLs compare largest. In our SQL dialectNULLs compare smallest (conveniently matches Rust, and cannot be easily changed).We will write more tests for sorting as part of #3922