Fix merge window optimizers#18967
Merged
feilong-liu merged 1 commit intoprestodb:masterfrom Feb 7, 2023
Merged
Conversation
2f66c91 to
793523d
Compare
pranjalssh
approved these changes
Jan 30, 2023
...n/src/test/java/com/facebook/presto/sql/planner/iterative/rule/TestMergeAdjacentWindows.java
Outdated
Show resolved
Hide resolved
8879349 to
55d8819
Compare
rschlussel
approved these changes
Feb 3, 2023
When the optimizer GatherAndMergeWindows merges or reorders two window nodes, it will check if one window node takes the other window's output as input or not. If yes, the two window nodes cannot be merged or reordered. However, the current implementation to check this dependency misses the input used in Frame. This commit fixes it by adding the Frame into account.
55d8819 to
36f6107
Compare
12 tasks
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.
What's the change?
When the optimizer
GatherAndMergeWindowsmerges or reorders two window nodes, it will check if one window node takes the other window's output as input or not. If yes, the two window nodes cannot be merged or reordered.However, the current implementation to check this dependency misses the input used in Frame. For example,
This query will throw error (GENERIC_INTERNAL_ERROR) Invalid node. Frame bounds ([rank, rank]) not in source plan output .
This PR fixes it by adding the Frame into account.
Test plan - (Please fill in how you tested your changes)
Add unit tests. Also run locally to make sure that the query above runs fine.