englefly opened a new pull request, #67021:
URL: https://github.com/apache/doris/pull/67021
### What problem does this PR solve?
Issue Number: close #xxx
Problem Summary:
A DISTINCT aggregate query that also contains a non-distinct aggregate
function (e.g. "select stddev_pop(distinct a), stddev_pop(b) from t") can fail
at runtime with:
Aggregate function NullableV2(stddev) result type check failed:
Column type String is not compatible with data type DOUBLE
The 3-phase DISTINCT plan (SplitAggMultiPhaseWithoutGbyKey) builds a dedup
aggregate that is one-phase GLOBAL(INPUT_TO_RESULT) with group-by keys, but
carries the non-distinct functions in INPUT_TO_BUFFER mode. The bucketed fusion
path introduced in the translator (shouldUseBucketedFusion /
visitBucketedFusion) treated this node as a genuine one-phase aggregate and
fused it into BucketedAggregationNode, hardcoding isPartial=false and
needsFinalize=true. The output tuple slot of a buffer-producing function is
Varchar (AggregateExpression maps productAggregateBuffer to the serialized
Varchar type), while the BE writes the function's final result (DOUBLE for
stddev) into that slot, so the BE result-type check fails.
Fix: reject bucketed fusion when the aggregate's output contains any
buffer-producing (partial) aggregate function. Such aggregates keep the regular
AggregationNode path, which serializes when isPartial. Genuine one-phase
aggregates (all functions INPUT_TO_RESULT) still fuse.
### Release note
None
### Check List (For Author)
- Test: Regression test
- Added DISTINCT stddev/var cases to bucketed_hash_agg.groovy (force the
3-phase distinct plan via parallel_pipeline_task_num=1); verified the suite
passes against the fixed FE, and that the originally failing query_p0/aggregate
suite passes as well.
- Behavior changed: No
- Does this need documentation: No
### What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
### Release note
None
### 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]