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 e60d31df28f [fix](nereids) make needsFinalize false for distinct agg
local phase (#58460)
e60d31df28f is described below
commit e60d31df28feb58b9be068626d0d96a1973b789e
Author: feiniaofeiafei <[email protected]>
AuthorDate: Fri Nov 28 11:32:19 2025 +0800
[fix](nereids) make needsFinalize false for distinct agg local phase
(#58460)
---
.../glue/translator/PhysicalPlanTranslator.java | 2 +-
.../translator/PhysicalPlanTranslatorTest.java | 41 +++++++++++++++++++++-
2 files changed, 41 insertions(+), 2 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java
index 5368d8b0dc5..aff3d5948d0 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java
@@ -1189,7 +1189,7 @@ public class PhysicalPlanTranslator extends
DefaultPlanVisitor<PlanFragment, Pla
aggregationNode.setNereidsId(aggregate.getId());
context.getNereidsIdToPlanNodeIdMap().put(aggregate.getId(),
aggregationNode.getId());
- if (isPartial) {
+ if (isPartial || aggregate.getAggregateParam().aggPhase.isLocal()) {
aggregationNode.unsetNeedsFinalize();
}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslatorTest.java
b/fe/fe-core/src/test/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslatorTest.java
index e3ac7aff29c..938187fef2b 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslatorTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslatorTest.java
@@ -35,9 +35,12 @@ import
org.apache.doris.nereids.trees.plans.physical.PhysicalOlapScan;
import org.apache.doris.nereids.trees.plans.physical.PhysicalProject;
import org.apache.doris.nereids.types.IntegerType;
import org.apache.doris.nereids.util.PlanConstructor;
+import org.apache.doris.planner.AggregationNode;
import org.apache.doris.planner.OlapScanNode;
import org.apache.doris.planner.PlanFragment;
import org.apache.doris.planner.PlanNode;
+import org.apache.doris.planner.Planner;
+import org.apache.doris.utframe.TestWithFeService;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@@ -45,12 +48,13 @@ import mockit.Injectable;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
-public class PhysicalPlanTranslatorTest {
+public class PhysicalPlanTranslatorTest extends TestWithFeService {
@Test
public void testOlapPrune(@Injectable LogicalProperties placeHolder)
throws Exception {
@@ -86,4 +90,39 @@ public class PhysicalPlanTranslatorTest {
planNode.collect(OlapScanNode.class::isInstance, scanNodeList);
Assertions.assertEquals(2,
scanNodeList.get(0).getTupleDesc().getSlots().size());
}
+
+ @Test
+ public void testAggNeedsFinalize() throws Exception {
+ createDatabase("test_db");
+ createTable("create table test_db.t(a int, b int) distributed by
hash(a) buckets 3 "
+ + "properties('replication_num' = '1');");
+
connectContext.getSessionVariable().setDisableNereidsRules("prune_empty_partition");
+ String querySql = "select b from test_db.t group by b";
+ Planner planner = getSQLPlanner(querySql);
+ Assertions.assertNotNull(planner);
+
+ List<PlanFragment> fragments = planner.getFragments();
+ Assertions.assertNotNull(fragments);
+ Assertions.assertFalse(fragments.isEmpty());
+
+ List<AggregationNode> aggNodes = new ArrayList<>();
+ for (PlanFragment fragment : fragments) {
+ PlanNode root = fragment.getPlanRoot();
+ if (root != null) {
+ root.collect(AggregationNode.class::isInstance, aggNodes);
+ }
+ }
+ Assertions.assertEquals(2, aggNodes.size());
+ Field needsFinalizeField =
AggregationNode.class.getDeclaredField("needsFinalize");
+ needsFinalizeField.setAccessible(true);
+ AggregationNode upperAggNode = aggNodes.get(0);
+ AggregationNode lowerAggNode = aggNodes.get(1);
+
+ boolean lowerNeedsFinalize =
needsFinalizeField.getBoolean(lowerAggNode);
+ Assertions.assertFalse(lowerNeedsFinalize,
+ "lower AggregationNode needsFinalize should be false");
+ boolean upperNeedsFinalize =
needsFinalizeField.getBoolean(upperAggNode);
+ Assertions.assertTrue(upperNeedsFinalize,
+ "upper AggregationNode needsFinalize should be true");
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]