Support LAG and LEAD window functions#82108
Conversation
|
Workflow [PR], commit [4bd5dfc] Summary: ❌
|
|
@Blargian, could you please review the documentation I wrote? |
Blargian
left a comment
There was a problem hiding this comment.
LGTM. I made some suggestions for a few small changes.
Co-authored-by: Shaun Struwig <[email protected]>
Co-authored-by: Shaun Struwig <[email protected]>
Co-authored-by: Shaun Struwig <[email protected]>
Co-authored-by: Shaun Struwig <[email protected]>
Co-authored-by: Shaun Struwig <[email protected]>
Co-authored-by: Shaun Struwig <[email protected]>
Co-authored-by: Shaun Struwig <[email protected]>
Co-authored-by: Shaun Struwig <[email protected]>
Seems unrelated. |
Cherry pick #82108 to 25.6: Support LAG and LEAD window functions
Backport #82108 to 25.6: Support LAG and LEAD window functions
| ```sql title="Query" | ||
| SELECT | ||
| fullName, | ||
| lead(year, 1, year) OVER (PARTITION BY category ORDER BY year ASC | ||
| ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING | ||
| ) AS year, | ||
| category, | ||
| motivation | ||
| FROM nobel_prize_laureates | ||
| WHERE category = 'physics' | ||
| ORDER BY year DESC | ||
| LIMIT 9 |
There was a problem hiding this comment.
Maybe I'm missing something, but isn't this example totally wrong/breaking a dataset?
This is pulling the year from the next row in the same category, which might not even be the same person. This is just shifting year that a prize in physics was awarded to the next year a prize was awarded, and has no relation to the current row other than being 1 offset within the category...
TLDR it's just mangling the dataset AFAICT, right? I did consult with o4-mini-high to make sure that I wasn't interpreting it wrong, but it seems like were just shifting the year and mangling the data for no reason. I'm not sure this is a useful example.
There was a problem hiding this comment.
@danthegoodman1 I think you are right. I will redo these examples.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Support
lagandleadwindow functions. Closes #9887.Documentation entry for user-facing changes