HappenLee commented on code in PR #68496:
URL: https://github.com/apache/doris/pull/68496#discussion_r4120624062
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/SetPreAggStatus.java:
##########
@@ -705,6 +709,31 @@ public PreAggStatus
visitAggregateFunction(AggregateFunction aggregateFunction,
.off(String.format("%s is not supported.",
aggregateFunction.toSql()));
}
+ @Override
+ public PreAggStatus visitMergeCombinator(MergeCombinator
combinator, AggregateType aggregateType) {
+ return checkAggStateCombinator(combinator, aggregateType);
+ }
+
+ @Override
+ public PreAggStatus visitUnionCombinator(UnionCombinator
combinator, AggregateType aggregateType) {
+ return checkAggStateCombinator(combinator, aggregateType);
+ }
+
+ private PreAggStatus checkAggStateCombinator(AggregateFunction
aggregateFunction,
+ AggregateType aggregateType) {
+ // GENERIC merges stored states with the same aggregate
function. A matching
+ // merge/union can consume the partial states directly;
REPLACE cannot.
+ // The caller requires a bare value slot, and the combinator
builder derives
+ // the nested argument types and nullability from that slot's
AggStateType.
+ AggStateType stateType = (AggStateType)
aggregateFunction.child(0).getDataType();
+ String functionName = ((Combinator)
aggregateFunction).getNestedFunction().getName();
+ if (aggregateType == AggregateType.GENERIC &&
stateType.getFunctionName().equals(functionName)) {
Review Comment:
Aggregate-state merge order is not guaranteed. PREAGGREGATION: OFF does not
provide a general guarantee about the order in which partial states are merged
either, so we should not rely on one particular merge order producing the exact
median.
The fixed-stride sampling bias is an issue in ReservoirSampler::merge
itself. The sampler should remain statistically correct across different merge
orders and groupings.
--
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]