mrhhsg commented on code in PR #68651:
URL: https://github.com/apache/doris/pull/68651#discussion_r4140284700
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/cost/CostModel.java:
##########
@@ -382,10 +386,17 @@ public Cost visitPhysicalHashAggregate(
inputStatistics.getRowCount() / beNumber, 0);
} else {
int factor = aggregate.getGroupByExpressions().isEmpty() ? 1 :
beNumber;
- // global
+ double rowCost = inputStatistics.getRowCount() / factor;
+ // Bucketed fusion discount: when the one-phase GLOBAL
INPUT_TO_RESULT
+ // aggregate is eligible for translator fusion (correctness +
data-volume
+ // gates are enforced by ChildrenPropertiesRegulator), apply a
discount
+ // to prefer this path over two-phase aggregation.
+ if (aggregate.getAggMode() == AggMode.INPUT_TO_RESULT
Review Comment:
Fixed in c6375a796ae. The aggregate-shape part of the fusion gate (GLOBAL +
INPUT_TO_RESULT, no partial / buffer-producing function, all functions support
two-phase execution, no pushed TopN) moved from the translator into
`AggregateUtils.isBucketedHashAggFusible`, and `CostModel`,
`ChildrenPropertiesRegulator`, `ChildOutputPropertyDeriver` and
`PhysicalPlanTranslator` now all use that one gate. The dedup aggregate of a
mixed DISTINCT / non-DISTINCT query therefore gets neither the cost discount
nor the one-phase-with-distribute exemption, so the plan deduplicates locally
before the exchange instead of shuffling the raw scan rows.
Tests:
`BucketedAggregateTranslatorTest.testMixedDistinctDedupAggregateIsNotPlannedAsBucketed`
(on the previous head it fails because the scan fragment feeds an exchange
directly), and explain / shape / result checks for `STDDEV_POP(DISTINCT id),
SUM(val) ... GROUP BY grp` in `bucketed_hash_agg.groovy`. The other bucketed
suites and the whole `nereids_rules_p0/agg_strategy` directory pass locally.
--
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]