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

   ### What problem does this PR solve?
   
   Issue Number: None
   
   Related PR: None
   
   Problem Summary:
   
   Existing `<aggregate>_state` plus `<aggregate>_union` constructs and 
serializes one aggregate state for every input row before merging those states. 
For queries with tens of millions of raw rows, this per-row state 
materialization can erase much of the pre-aggregation benefit.
   
   This PR adds a generic `<aggregate>_combine(...)` combinator. It feeds raw 
arguments directly into the nested aggregate function and emits one compatible 
`AggState` per group. For example, `avg_combine(x)` is aggregation-equivalent 
to `avg_union(avg_state(x))`, while avoiding a serialized AVG state for every 
source row. The resulting state remains consumable by the existing `_union` and 
`_merge` combinators.
   
   The BE wrapper preserves the nested aggregate state layout and delegates raw 
accumulation, partial serialization, merge/deserialization, nullable handling, 
and fixed-length serialized column creation. Nereids resolves and translates 
the generic combinator and supports MV roll-up through the matching `_union` 
function. Zero-argument aggregates, DISTINCT, and aggregate ORDER BY 
expressions are rejected for now.
   
   ### Release note
   
   Add the experimental `<aggregate>_combine(...)` combinator for directly 
producing reusable aggregate states.
   
   ### Check List (For Author)
   
   - Test
       - [x] Regression test
       - [x] Unit Test
       - [ ] Manual test (add detailed scripts or steps below)
       - [ ] No need to test or manual test. Explain why:
   
   Regression coverage: `test_agg_state_avg`, including nullable input, 
all-null input, grouped partial aggregation, and compatibility with 
`avg_union(avg_state(...))`.
   
   Unit coverage: `AggregateStateCombineTest` and `CombineCombinatorTest`. Full 
BE and FE builds also passed; clang-tidy reported no warnings for the changed 
BE files.
   
   - Behavior changed:
       - [ ] No.
       - [x] Yes. Adds a new aggregate-state combinator.
   
   - Does this need documentation?
       - [x] No. The function is covered by the existing experimental AggState 
feature.
       - [ ] Yes.


-- 
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