Fix min_by/max_by for window function evaluation#21793
Merged
feilong-liu merged 1 commit intoprestodb:masterfrom Jan 30, 2024
Merged
Fix min_by/max_by for window function evaluation#21793feilong-liu merged 1 commit intoprestodb:masterfrom
feilong-liu merged 1 commit intoprestodb:masterfrom
Conversation
feilong-liu
commented
Jan 26, 2024
Contributor
Author
There was a problem hiding this comment.
The heap was restored after the change, hence do not need to update the memory usage.
6ae7492 to
36a780e
Compare
64 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.
Description
Fix issue #21653
Motivation and Context
As described in #21653, the min_by/max_by are not returning the expected result, due to the optimization in window function expression. A similar bug in min/max function was fixed in #18615
Impact
Fix the correctness issue for max_by/min_by in window function.
The queries with the following pattern will be impacted:
Notice that this change will also slightly degrade the performance of this aggregation function. The fix is to restore the accumulation state after outputting the result, which is not needed if not used in window function. However, to mitigate this, we need to know whether it's used in window function in the implementation, which makes the code complex and not worth the benefit.
Test Plan
Tested with the query in the issue.
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.