HappenLee opened a new pull request, #67805:
URL: https://github.com/apache/doris/pull/67805
### What problem does this PR solve?
Issue Number: N/A
Related PR: N/A
Problem Summary:
AggState types describe argument types but do not include constant parameter
values. For example, `topn_merge` over a `UNION ALL` of `topn_state('a', 1)`
and `topn_state('a', 3)` can combine incompatible states. TopN previously
overwrote the destination N/capacity, making results depend on merge order.
Other configurable aggregates silently adopted incompatible settings; legacy
percentile arrays could index beyond the destination state when quantile counts
differed.
Reject incompatible populated states with `INVALID_ARGUMENT`, using
`UNLIKELY` for the mismatch paths. Apply the same invariant to TopN variants,
histograms, percentile variants, limited collect, group_concat,
intersect_count, exponential moving average, sequence functions and both
window_funnel implementations. Preserve empty-state identity and reset
behavior, initialize approximate percentile digests with the source
compression, and keep serialization formats unchanged.
### Release note
Merging aggregate states with incompatible parameters now returns an error
instead of producing incorrect results or risking an out-of-bounds access.
### Check List (For Author)
- Test:
- [x] Regression test: `test_agg_state_parameters` covers both `_merge`
and `_union`, both input orders, and 39 incompatible parameter pairs.
- [x] Unit Test: 56 tests passed, including parameter compatibility,
serialized merge, empty states, reset and compatible-state results, plus
existing related aggregate tests.
- Local validation: BE ASAN and FE builds, the regression suite (156
expected errors), clang-format 16, and BE header hygiene passed. Local BE
startup required OpenBLAS `USE_OPENMP=FALSE` to avoid a toolchain
initialization crash; this build-cache setting is not part of the patch. Full
clang-tidy is blocked by the existing unmatched `NOLINTEND` in
`be/src/core/types.h`; diagnostics on the changed code have been addressed.
- Behavior changed:
- [x] Yes. Incompatible aggregate state parameters fail with
`INVALID_ARGUMENT`; matching states retain their semantics.
- 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]