Extend filtered aggregation optimizer to support only masked partial aggregation cases#25171
Merged
feilong-liu merged 1 commit intoprestodb:masterfrom Jun 3, 2025
Merged
Conversation
cf74f97 to
e322aec
Compare
kaikalur
reviewed
May 21, 2025
...n/java/com/facebook/presto/sql/planner/optimizations/MergePartialAggregationsWithFilter.java
Outdated
Show resolved
Hide resolved
…aggregation cases
e322aec to
40b134f
Compare
kaikalur
approved these changes
Jun 2, 2025
jaystarshot
approved these changes
Jun 2, 2025
Member
jaystarshot
left a comment
There was a problem hiding this comment.
I think the default case when one mask, one normal is always beneficial but this new case might not be beneficial for high cardinality cases so we should try to make the first one on by default later
Contributor
But I hope adding the disjunction mitigates that? We will run some benchmarks and see. |
6 tasks
This was referenced Jul 4, 2025
This was referenced Jul 24, 2025
6 tasks
Member
|
Hi @feilong-liu , I am working on the release notes for this PR. Can you revise the PR note and use more user-understandable wording? |
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
The current optimizer MergePartialAggregationsWithFilter only supports case where there are both aggregations with and without filter on the same filter. For example,
select sum(totalprice), sum(totalprice) filter (where orderpriority='2-HIGH') from orders group by orderdatewill work, but
select sum(totalprice) filter (where orderstatus='F'), sum(totalprice) filter (where orderpriority='2-HIGH') from orders group by orderdatewill not work.
In this change, I extend it to work for the second case too.
Motivation and Context
Extend existing optimizer to a broader range of queries.
Impact
Extend existing optimizer to a broader range of queries.
Test Plan
Add unit tests
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.