This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new e137ae943b3 [fix](nereids) Not use rule
FOUR_PHASE_AGGREGATE_WITH_DISTINCT_WITH_FULL_DISTRIBUTE when
mustUseMultiDistinctAgg (#51099)
e137ae943b3 is described below
commit e137ae943b31c24830f4d69501ce932ef2fad2e4
Author: feiniaofeiafei <[email protected]>
AuthorDate: Thu May 22 11:37:49 2025 +0800
[fix](nereids) Not use rule
FOUR_PHASE_AGGREGATE_WITH_DISTINCT_WITH_FULL_DISTRIBUTE when
mustUseMultiDistinctAgg (#51099)
### What problem does this PR solve?
Related PR: #35871
Problem Summary:
select
/*+SET_VAR(disable_nereids_rules='TWO_PHASE_AGGREGATE_SINGLE_DISTINCT_TO_MULTI')*/
id,group_concat(distinct field2 order by field1)
from agg_4_phase_tbl2
group by id
this sql will report error : VSlotRef a have invalid slot id. The
group_concat argument field1 is not output by children, because when do
local distinct agg, only output the group by key id and distinct slot
field2.
This pr will not perform
FOUR_PHASE_AGGREGATE_WITH_DISTINCT_WITH_FULL_DISTRIBUTE rule when agg
functions have group_concat with distinct and order by key.
---
.../nereids/rules/implementation/AggregateStrategies.java | 2 ++
regression-test/suites/nereids_syntax_p0/agg_4_phase.groovy | 10 ++++++++++
2 files changed, 12 insertions(+)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java
index 0a1b1c4e9b2..fa511631fc6 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java
@@ -62,6 +62,7 @@ import org.apache.doris.nereids.trees.plans.AggMode;
import org.apache.doris.nereids.trees.plans.AggPhase;
import org.apache.doris.nereids.trees.plans.GroupPlan;
import org.apache.doris.nereids.trees.plans.Plan;
+import org.apache.doris.nereids.trees.plans.algebra.Aggregate;
import org.apache.doris.nereids.trees.plans.algebra.Project;
import org.apache.doris.nereids.trees.plans.logical.LogicalAggregate;
import org.apache.doris.nereids.trees.plans.logical.LogicalFileScan;
@@ -421,6 +422,7 @@ public class AggregateStrategies implements
ImplementationRuleFactory {
return couldConvertToMulti(agg);
})
.when(agg ->
agg.supportAggregatePhase(AggregatePhase.FOUR))
+ .whenNot(Aggregate::mustUseMultiDistinctAgg)
.thenApplyMulti(ctx -> {
Function<List<Expression>, RequireProperties>
secondPhaseRequireGroupByAndDistinctHash =
groupByAndDistinct -> RequireProperties.of(
diff --git a/regression-test/suites/nereids_syntax_p0/agg_4_phase.groovy
b/regression-test/suites/nereids_syntax_p0/agg_4_phase.groovy
index ed69d0018c9..e2113ee7571 100644
--- a/regression-test/suites/nereids_syntax_p0/agg_4_phase.groovy
+++ b/regression-test/suites/nereids_syntax_p0/agg_4_phase.groovy
@@ -85,4 +85,14 @@ suite("agg_4_phase") {
from agg_4_phase_tbl2
group by id
order by id"""
+
+ test {
+ sql """select
+
/*+SET_VAR(disable_nereids_rules='TWO_PHASE_AGGREGATE_SINGLE_DISTINCT_TO_MULTI')*/
+ id,group_concat(distinct field2 order by field1)
+ from agg_4_phase_tbl2
+ group by id
+ """
+ exception """lowestCostPlans with physicalProperties(GATHER) doesn't
exist in root group"""
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]