-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Unexpected result when using nth_value #24758
Comments
@kasiafi can you take a look? |
The default window frame is RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, source: https://trino.io/docs/current/sql/select.html, when we process the first row in the partition, we only have the first row in the current frame, so NTH_VALUE functioncall on offset 2 will return NULL. In order to avoid this, you need to specify frame as RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING, like the following
|
I find it quite odd that there are different behaviours depending on whether you apply ordering or not but it seems consistent with other engines... perhaps an example rather than a description in the documentation could help clear things up? |
The documentation states:-
With a MRE
This returns
But I would expect
When the NTH_VALUE offset is increased we end up with more NULL values, like the window above the offset is being ignored.
The text was updated successfully, but these errors were encountered: