-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-51757][SQL] Fix LEAD/LAG Function Offset Exceeds Window Group Size #50552
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
Closed
Closed
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
993f6a4
window function bug fix
xin-aurora b9177ec
Merge branch 'apache:master' into windowFuncFix
xin-aurora b147e77
Merge branch 'apache:master' into windowFuncFix
xin-aurora 997cc49
Merge branch 'apache:master' into windowFuncFix
xin-aurora e8fe757
update comments
xin-aurora bfcf962
Merge branch 'apache:master' into windowFuncFix
xin-aurora df1d849
Merge branch 'apache:master' into windowFuncFix
xin-aurora 2cc882c
Handle literal and non-literal defaults separately
xin-aurora 20d46cb
Merge branch 'apache:master' into windowFuncFix
xin-aurora 10951fa
Merge branch 'apache:master' into windowFuncFix
xin-aurora f193945
Merge branch 'apache:master' into windowFuncFix
xin-aurora f4dbd85
Merge branch 'apache:master' into windowFuncFix
xin-aurora 0ddb79d
remove duplicate val
xin-aurora 855f955
fix early evaluation of onlyLiteralNulls
xin-aurora 9243bb5
Merge branch 'apache:master' into windowFuncFix
xin-aurora ee28495
update onlyLiteralNulls
xin-aurora a4aad86
test merge
xin-aurora fc6d271
Merge branch 'apache:master' into windowFuncFix
xin-aurora 4d36ca5
fix val onlyLiterals for any foldable expression
xin-aurora 6ad5f40
Merge branch 'apache:master' into windowFuncFix
xin-aurora 8994beb
update onlyLiterals
xin-aurora e99ddda
Merge branch 'apache:master' into windowFuncFix
xin-aurora 469baa9
Merge branch 'apache:master' into windowFuncFix
xin-aurora 650cc1b
Merge branch 'apache:master' into windowFuncFix
xin-aurora File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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.
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.
if the code is not needed, just remove them. and add some comments to explain the reason
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.
Is it the only place? Seems we should never run
fillDefaultValueinprepareas the default value can be an expression that references attributes.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.
It seems all the existing tests just cover the default value as
Literal.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.
And I think it's not related to the partition size.
The cause is apply expression on empty row.
We can check the default expression and apply
fillDefaultValue(currentRow)in write if it is not a Literal, or apply it is in prepare if it is a literal.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.
Edit the comments to include the reason
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.
I found this is the only place to run
fillDefaultValueinprepare. I updated thewriteinFrameLessOffsetWindowFunctionFrameto callfillDefaultValueas well.I noticed that the
writeinUnboundedPrecedingOffsetWindowFunctionFramealso relies onprepareto handle cases where offset exceeds the window group size. However, I haven't found a query that triggers this method. It's possible thatwriteinUnboundedPrecedingOffsetWindowFunctionFramealso needs to be updated.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.
Thank you for the suggestions! We had a similar idea for fixing this issue. I've updated
writeinFrameLessOffsetWindowFunctionFrameto callfillDefaultValue(currentRow).