feiniaofeiafei opened a new pull request, #63690:
URL: https://github.com/apache/doris/pull/63690

   ### What problem does this PR solve?
   
   Issue Number: close #xxx
   
   Related PR: #xxx
   
   Problem Summary:
   The current eager aggregation push-down in Nereids mainly covers one-sided 
pre-aggregation across joins. When aggregate functions reference columns from 
both sides of an inner join, the optimizer usually can only push aggregation to 
one side, or give up push-down entirely. As a result, the input size before the 
join cannot be reduced further, and optimization opportunities for more complex 
join shapes are limited.
   
   This PR extends `PushDownAggregation` to support bilateral eager aggregation 
push-down for eligible inner joins. For aggregates such as sum/count/min/max, 
the optimizer can build partial aggregates on both join branches and restore 
join multiplicity during the upper rollup phase using the `count(*)` 
information produced by the opposite branch. In this process, sum/count are 
scaled by branch multiplicity before the final aggregation, while min/max are 
rolled up directly without multiplier adjustment.
   
   To support this path, this PR also adds the required state propagation logic 
across join/project/union/filter during bilateral rewrite, and introduces 
`force_eager_agg_hint` for testing and debugging. The hint is matched by 
aggregate-function key, but its effect is applied at the current candidate 
push-down branch level: if any matched entry in a branch is `nopush`, push-down 
is disabled for that branch; otherwise, if any matched entry is `push`, 
push-down may be forced for that branch, and the other aggregates in the same 
branch follow that branch-level decision.
   
   In addition, this PR moves init join order before eager aggregation so that 
bilateral push-down can work on a more stable join shape, and adds 
corresponding FE unit tests and query cases.
   
   ### Release note
   
   The Nereids optimizer now supports more eager aggregation push-down 
scenarios. For eligible inner joins, it can pre-aggregate both join branches 
and provides `force_eager_agg_hint` for branch-level testing/debug control.
   
   
   ### Check List (For Author)
   
   - Test <!-- At least one of them must be included. -->
       - [ ] Regression test
       - [ ] Unit Test
       - [ ] Manual test (add detailed scripts or steps below)
       - [ ] No need to test or manual test. Explain why:
           - [ ] This is a refactor/code format and no logic has been changed.
           - [ ] Previous test can cover this change.
           - [ ] No code files have been changed.
           - [ ] Other reason <!-- Add your reason?  -->
   
   - Behavior changed:
       - [ ] No.
       - [ ] Yes. <!-- Explain the behavior change -->
   
   - Does this need documentation?
       - [ ] No.
       - [ ] Yes. <!-- Add document PR link here. eg: 
https://github.com/apache/doris-website/pull/1214 -->
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label <!-- Add branch pick label that this PR should 
merge into -->
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to