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

   ### What problem does this PR solve?
   
   Issue Number: N/A
   
   Related PR: #58031
   
   Problem Summary:
   
   `count_union(count_state())` can crash the BE while initializing an 
aggregate evaluator. FE represents zero-argument count as `count(*)` and sends 
an AggState with an empty subtype list, but `DataTypeAggState` unconditionally 
reads the first subtype to infer the nested result type.
   
   Handle zero-argument count with its explicit Int64 result type while 
preserving the empty argument signature and reusing the existing count 
implementation. Reject unsupported zero-argument AggState functions with 
`INVALID_ARGUMENT` before invoking creators that require an input type. 
Parameterized aggregate handling and serialization formats remain unchanged.
   
   ### Release note
   
   Fix a BE crash when constructing zero-argument count aggregate states, 
including queries using `count_union(count_state())` and 
`count_merge(count_state())`.
   
   ### Check List (For Author)
   
   - Test:
       - [x] Unit Test: 20 ASAN tests passed 
(`DataTypeAggStateZeroArgumentTest.*`, `Params/DataTypeAggStateTest.*`, 
`AggregateFunctionCountTest.*`). New coverage includes empty/one/three/8193-row 
state serialization and merge, plus invalid empty-argument functions.
       - [x] Regression test: `test_count_state_zero_arguments` passed on an 
isolated ASAN BE cluster. Generated expected output with `-forceGenOut`, then 
passed a normal comparison run. Covers the original crash, empty input, 
nullable input, 10001 rows, grouped union, and parameterized Decimal 
aggregates. BE remained alive afterward.
       - BE and FE build passed with `./build.sh --be --fe -j 48`; clang-format 
16 and build hygiene checks passed.
       - clang-tidy reported no diagnostics on changed lines. The script could 
not pass because the base branch has an unmatched `NOLINTEND` in 
`be/src/core/types.h`; other emitted diagnostics also refer to unchanged code.
   - Behavior changed:
       - [x] Yes. Zero-argument count AggState construction succeeds instead of 
crashing; unsupported empty-argument states raise an error.
   - Does this need documentation?
       - [x] No.
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label
   


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