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 fd5d7d6097 [refactor](Nereids) remove local sort (#16819)
fd5d7d6097 is described below
commit fd5d7d6097372cee23cba67ef460966410819489
Author: 谢健 <[email protected]>
AuthorDate: Fri Feb 17 18:52:41 2023 +0800
[refactor](Nereids) remove local sort (#16819)
After adding phase in sort, the locatSort is no longer needed
change the order of sortPhase in constructor
---
.../apache/doris/nereids/cost/CostCalculator.java | 14 ---
.../glue/translator/PhysicalPlanTranslator.java | 11 ---
.../processor/post/RuntimeFilterPruner.java | 10 --
.../properties/ChildOutputPropertyDeriver.java | 10 --
.../apache/doris/nereids/properties/OrderSpec.java | 8 +-
.../nereids/properties/RequestPropertyDeriver.java | 8 --
.../LogicalSortToPhysicalQuickSort.java | 10 +-
.../implementation/LogicalTopNToPhysicalTopN.java | 8 +-
.../doris/nereids/stats/StatsCalculator.java | 6 --
.../trees/plans/physical/AbstractPhysicalSort.java | 9 +-
.../plans/physical/PhysicalLocalQuickSort.java | 104 ---------------------
.../trees/plans/physical/PhysicalQuickSort.java | 29 +++---
.../nereids/trees/plans/physical/PhysicalTopN.java | 29 +++---
.../nereids/trees/plans/visitor/PlanVisitor.java | 5 -
.../properties/ChildOutputPropertyDeriverTest.java | 7 +-
.../doris/nereids/trees/plans/PlanEqualsTest.java | 12 +--
16 files changed, 54 insertions(+), 226 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/cost/CostCalculator.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/cost/CostCalculator.java
index cabdce770b..b0ac15b93f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/cost/CostCalculator.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/cost/CostCalculator.java
@@ -31,7 +31,6 @@ import
org.apache.doris.nereids.trees.plans.physical.PhysicalFileScan;
import org.apache.doris.nereids.trees.plans.physical.PhysicalGenerate;
import org.apache.doris.nereids.trees.plans.physical.PhysicalHashAggregate;
import org.apache.doris.nereids.trees.plans.physical.PhysicalHashJoin;
-import org.apache.doris.nereids.trees.plans.physical.PhysicalLocalQuickSort;
import org.apache.doris.nereids.trees.plans.physical.PhysicalNestedLoopJoin;
import org.apache.doris.nereids.trees.plans.physical.PhysicalOlapScan;
import org.apache.doris.nereids.trees.plans.physical.PhysicalProject;
@@ -166,19 +165,6 @@ public class CostCalculator {
childStatistics.getRowCount());
}
- @Override
- public CostEstimate visitPhysicalLocalQuickSort(
- PhysicalLocalQuickSort<? extends Plan> sort, PlanContext
context) {
- // TODO: consider two-phase sort and enforcer.
- StatsDeriveResult statistics = context.getStatisticsWithCheck();
- StatsDeriveResult childStatistics = context.getChildStatistics(0);
-
- return CostEstimate.of(
- childStatistics.getRowCount(),
- statistics.getRowCount(),
- 0);
- }
-
@Override
public CostEstimate visitPhysicalDistribute(
PhysicalDistribute<? extends Plan> distribute, PlanContext
context) {
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 0033da09d8..a7af0a72a6 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
@@ -809,17 +809,6 @@ public class PhysicalPlanTranslator extends
DefaultPlanVisitor<PlanFragment, Pla
return sortNode;
}
- @Override
- public PlanFragment visitAbstractPhysicalSort(
- AbstractPhysicalSort<? extends Plan> sort,
- PlanTranslatorContext context) {
- PlanFragment childFragment = sort.child(0).accept(this, context);
- PlanNode childNode = childFragment.getPlanRoot();
- SortNode sortNode = translateSortNode(sort, childNode, context);
- childFragment.addPlanRoot(sortNode);
- return childFragment;
- }
-
/**
* the contract of hash join node with BE
* 1. hash join contains 3 types of predicates:
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterPruner.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterPruner.java
index afca448aff..48abc974a1 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterPruner.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterPruner.java
@@ -30,7 +30,6 @@ import
org.apache.doris.nereids.trees.plans.physical.PhysicalFilter;
import org.apache.doris.nereids.trees.plans.physical.PhysicalHashAggregate;
import org.apache.doris.nereids.trees.plans.physical.PhysicalHashJoin;
import org.apache.doris.nereids.trees.plans.physical.PhysicalLimit;
-import org.apache.doris.nereids.trees.plans.physical.PhysicalLocalQuickSort;
import org.apache.doris.nereids.trees.plans.physical.PhysicalOlapScan;
import org.apache.doris.nereids.trees.plans.physical.PhysicalProject;
import org.apache.doris.nereids.trees.plans.physical.PhysicalQuickSort;
@@ -157,15 +156,6 @@ public class RuntimeFilterPruner extends PlanPostProcessor
{
return distribute;
}
- public PhysicalLocalQuickSort
visitPhysicalLocalQuickSort(PhysicalLocalQuickSort<? extends Plan> sort,
- CascadesContext context) {
- sort.child().accept(this, context);
- if
(context.getRuntimeFilterContext().isEffectiveSrcNode(sort.child())) {
- context.getRuntimeFilterContext().addEffectiveSrcNode(sort);
- }
- return sort;
- }
-
public PhysicalAssertNumRows
visitPhysicalAssertNumRows(PhysicalAssertNumRows<? extends Plan> assertNumRows,
CascadesContext context) {
assertNumRows.child().accept(this, context);
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriver.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriver.java
index 3f2ee557ef..35c6261e99 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriver.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriver.java
@@ -34,7 +34,6 @@ import
org.apache.doris.nereids.trees.plans.physical.PhysicalGenerate;
import org.apache.doris.nereids.trees.plans.physical.PhysicalHashAggregate;
import org.apache.doris.nereids.trees.plans.physical.PhysicalHashJoin;
import org.apache.doris.nereids.trees.plans.physical.PhysicalLimit;
-import org.apache.doris.nereids.trees.plans.physical.PhysicalLocalQuickSort;
import org.apache.doris.nereids.trees.plans.physical.PhysicalNestedLoopJoin;
import org.apache.doris.nereids.trees.plans.physical.PhysicalOlapScan;
import org.apache.doris.nereids.trees.plans.physical.PhysicalProject;
@@ -101,15 +100,6 @@ public class ChildOutputPropertyDeriver extends
PlanVisitor<PhysicalProperties,
}
}
- @Override
- public PhysicalProperties visitPhysicalLocalQuickSort(
- PhysicalLocalQuickSort<? extends Plan> sort, PlanContext context) {
- Preconditions.checkState(childrenOutputProperties.size() == 1);
- return new PhysicalProperties(
- childrenOutputProperties.get(0).getDistributionSpec(),
- new OrderSpec(sort.getOrderKeys()));
- }
-
@Override
public PhysicalProperties visitPhysicalTopN(PhysicalTopN<? extends Plan>
topN, PlanContext context) {
Preconditions.checkState(childrenOutputProperties.size() == 1);
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/OrderSpec.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/OrderSpec.java
index fc283f3fac..1f85bbb3b7 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/OrderSpec.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/OrderSpec.java
@@ -66,8 +66,8 @@ public class OrderSpec {
*/
public GroupExpression addLocalQuickSortEnforcer(Group child) {
return new GroupExpression(
- new PhysicalQuickSort<>(orderKeys,
child.getLogicalProperties(),
- new GroupPlan(child), SortPhase.LOCAL_SORT),
+ new PhysicalQuickSort<>(orderKeys, SortPhase.LOCAL_SORT,
child.getLogicalProperties(),
+ new GroupPlan(child)),
Lists.newArrayList(child)
);
}
@@ -77,8 +77,8 @@ public class OrderSpec {
*/
public GroupExpression addGlobalQuickSortEnforcer(Group child) {
return new GroupExpression(
- new PhysicalQuickSort<>(orderKeys,
child.getLogicalProperties(),
- new GroupPlan(child), SortPhase.MERGE_SORT),
+ new PhysicalQuickSort<>(orderKeys, SortPhase.MERGE_SORT,
child.getLogicalProperties(),
+ new GroupPlan(child)),
Lists.newArrayList(child)
);
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/RequestPropertyDeriver.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/RequestPropertyDeriver.java
index 87ac8c7cb9..77d17f2701 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/RequestPropertyDeriver.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/RequestPropertyDeriver.java
@@ -32,7 +32,6 @@ import org.apache.doris.nereids.trees.plans.Plan;
import org.apache.doris.nereids.trees.plans.physical.PhysicalAssertNumRows;
import org.apache.doris.nereids.trees.plans.physical.PhysicalGenerate;
import org.apache.doris.nereids.trees.plans.physical.PhysicalHashJoin;
-import org.apache.doris.nereids.trees.plans.physical.PhysicalLocalQuickSort;
import org.apache.doris.nereids.trees.plans.physical.PhysicalNestedLoopJoin;
import org.apache.doris.nereids.trees.plans.physical.PhysicalQuickSort;
import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
@@ -104,13 +103,6 @@ public class RequestPropertyDeriver extends
PlanVisitor<Void, PlanContext> {
return null;
}
- @Override
- public Void visitPhysicalLocalQuickSort(PhysicalLocalQuickSort<? extends
Plan> sort, PlanContext context) {
- // TODO: rethink here, should we throw exception directly?
- addRequestPropertyToChildren(PhysicalProperties.ANY);
- return null;
- }
-
@Override
public Void visitPhysicalHashJoin(PhysicalHashJoin<? extends Plan, ?
extends Plan> hashJoin, PlanContext context) {
JoinHint hint = hashJoin.getHint();
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/LogicalSortToPhysicalQuickSort.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/LogicalSortToPhysicalQuickSort.java
index aceccdfb7e..a8cb23a4f8 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/LogicalSortToPhysicalQuickSort.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/LogicalSortToPhysicalQuickSort.java
@@ -40,15 +40,15 @@ public class LogicalSortToPhysicalQuickSort extends
OneImplementationRuleFactory
private List<PhysicalQuickSort<? extends Plan>> twoPhaseSort(LogicalSort
logicalSort) {
PhysicalQuickSort localSort = new
PhysicalQuickSort(logicalSort.getOrderKeys(),
- logicalSort.getLogicalProperties(), logicalSort.child(0),
SortPhase.LOCAL_SORT);
+ SortPhase.LOCAL_SORT, logicalSort.getLogicalProperties(),
logicalSort.child(0));
PhysicalQuickSort twoPhaseSort = new PhysicalQuickSort<>(
logicalSort.getOrderKeys(),
- logicalSort.getLogicalProperties(),
- localSort, SortPhase.MERGE_SORT);
+ SortPhase.MERGE_SORT, logicalSort.getLogicalProperties(),
+ localSort);
PhysicalQuickSort onePhaseSort = new PhysicalQuickSort<>(
logicalSort.getOrderKeys(),
- logicalSort.getLogicalProperties(),
- localSort.child(0), SortPhase.GATHER_SORT);
+ SortPhase.GATHER_SORT, logicalSort.getLogicalProperties(),
+ localSort.child(0));
return Lists.newArrayList(twoPhaseSort, onePhaseSort);
}
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/LogicalTopNToPhysicalTopN.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/LogicalTopNToPhysicalTopN.java
index e6c15203c8..ac90ff8acc 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/LogicalTopNToPhysicalTopN.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/LogicalTopNToPhysicalTopN.java
@@ -40,12 +40,12 @@ public class LogicalTopNToPhysicalTopN extends
OneImplementationRuleFactory {
private List<PhysicalTopN<? extends Plan>> twoPhaseSort(LogicalTopN
logicalTopN) {
PhysicalTopN localSort = new PhysicalTopN(logicalTopN.getOrderKeys(),
logicalTopN.getLimit(),
- logicalTopN.getOffset(), logicalTopN.getLogicalProperties(),
logicalTopN.child(0),
- SortPhase.LOCAL_SORT);
+ logicalTopN.getOffset(), SortPhase.LOCAL_SORT,
logicalTopN.getLogicalProperties(), logicalTopN.child(0)
+ );
PhysicalTopN twoPhaseSort = new
PhysicalTopN<>(logicalTopN.getOrderKeys(), logicalTopN.getLimit(),
- logicalTopN.getOffset(), logicalTopN.getLogicalProperties(),
localSort, SortPhase.MERGE_SORT);
+ logicalTopN.getOffset(), SortPhase.MERGE_SORT,
logicalTopN.getLogicalProperties(), localSort);
PhysicalTopN onePhaseSort = new
PhysicalTopN<>(logicalTopN.getOrderKeys(), logicalTopN.getLimit(),
- logicalTopN.getOffset(), logicalTopN.getLogicalProperties(),
localSort.child(0), SortPhase.GATHER_SORT);
+ logicalTopN.getOffset(), SortPhase.GATHER_SORT,
logicalTopN.getLogicalProperties(), localSort.child(0));
return Lists.newArrayList(twoPhaseSort, onePhaseSort);
}
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java
index c29793238d..214c8a97bd 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java
@@ -70,7 +70,6 @@ import
org.apache.doris.nereids.trees.plans.physical.PhysicalHashAggregate;
import org.apache.doris.nereids.trees.plans.physical.PhysicalHashJoin;
import org.apache.doris.nereids.trees.plans.physical.PhysicalIntersect;
import org.apache.doris.nereids.trees.plans.physical.PhysicalLimit;
-import org.apache.doris.nereids.trees.plans.physical.PhysicalLocalQuickSort;
import org.apache.doris.nereids.trees.plans.physical.PhysicalNestedLoopJoin;
import org.apache.doris.nereids.trees.plans.physical.PhysicalOlapScan;
import org.apache.doris.nereids.trees.plans.physical.PhysicalOneRowRelation;
@@ -301,11 +300,6 @@ public class StatsCalculator extends
DefaultPlanVisitor<StatsDeriveResult, Void>
return computeTopN(topN);
}
- @Override
- public StatsDeriveResult
visitPhysicalLocalQuickSort(PhysicalLocalQuickSort<? extends Plan> sort, Void
context) {
- return groupExpression.childStatistics(0);
- }
-
@Override
public StatsDeriveResult visitPhysicalHashJoin(
PhysicalHashJoin<? extends Plan, ? extends Plan> hashJoin, Void
context) {
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/AbstractPhysicalSort.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/AbstractPhysicalSort.java
index 6ade59df87..0b779030b9 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/AbstractPhysicalSort.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/AbstractPhysicalSort.java
@@ -46,8 +46,8 @@ public abstract class AbstractPhysicalSort<CHILD_TYPE extends
Plan> extends Phys
* Constructor of AbstractPhysicalSort.
*/
public AbstractPhysicalSort(PlanType type, List<OrderKey> orderKeys,
- Optional<GroupExpression> groupExpression, LogicalProperties
logicalProperties,
- CHILD_TYPE child, SortPhase phase) {
+ SortPhase phase, Optional<GroupExpression> groupExpression,
LogicalProperties logicalProperties,
+ CHILD_TYPE child) {
super(type, groupExpression, logicalProperties, child);
this.orderKeys =
ImmutableList.copyOf(Objects.requireNonNull(orderKeys, "orderKeys can not be
null"));
this.phase = phase;
@@ -57,9 +57,8 @@ public abstract class AbstractPhysicalSort<CHILD_TYPE extends
Plan> extends Phys
* Constructor of AbstractPhysicalSort.
*/
public AbstractPhysicalSort(PlanType type, List<OrderKey> orderKeys,
- Optional<GroupExpression> groupExpression, LogicalProperties
logicalProperties,
- PhysicalProperties physicalProperties, StatsDeriveResult
statsDeriveResult, CHILD_TYPE child,
- SortPhase phase) {
+ SortPhase phase, Optional<GroupExpression> groupExpression,
LogicalProperties logicalProperties,
+ PhysicalProperties physicalProperties, StatsDeriveResult
statsDeriveResult, CHILD_TYPE child) {
super(type, groupExpression, logicalProperties, physicalProperties,
statsDeriveResult, child);
this.orderKeys =
ImmutableList.copyOf(Objects.requireNonNull(orderKeys, "orderKeys can not be
null"));
this.phase = phase;
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalLocalQuickSort.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalLocalQuickSort.java
deleted file mode 100644
index ba51dfb630..0000000000
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalLocalQuickSort.java
+++ /dev/null
@@ -1,104 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.nereids.trees.plans.physical;
-
-import org.apache.doris.nereids.memo.GroupExpression;
-import org.apache.doris.nereids.properties.LogicalProperties;
-import org.apache.doris.nereids.properties.OrderKey;
-import org.apache.doris.nereids.properties.PhysicalProperties;
-import org.apache.doris.nereids.trees.plans.Plan;
-import org.apache.doris.nereids.trees.plans.PlanType;
-import org.apache.doris.nereids.trees.plans.SortPhase;
-import org.apache.doris.nereids.trees.plans.algebra.Sort;
-import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
-import org.apache.doris.nereids.util.Utils;
-import org.apache.doris.statistics.StatsDeriveResult;
-
-import com.google.common.base.Preconditions;
-
-import java.util.List;
-import java.util.Optional;
-
-/**
- * physical local sort for physical properties enforcer.
- */
-public class PhysicalLocalQuickSort<CHILD_TYPE extends Plan> extends
AbstractPhysicalSort<CHILD_TYPE> implements Sort {
-
- public PhysicalLocalQuickSort(List<OrderKey> orderKeys,
- LogicalProperties logicalProperties, CHILD_TYPE child) {
- this(orderKeys, Optional.empty(), logicalProperties, child);
- }
-
- /**
- * Constructor of PhysicalLocalQuickSort.
- */
- public PhysicalLocalQuickSort(List<OrderKey> orderKeys,
- Optional<GroupExpression> groupExpression, LogicalProperties
logicalProperties,
- CHILD_TYPE child) {
- super(PlanType.PHYSICAL_LOCAL_QUICK_SORT, orderKeys, groupExpression,
- logicalProperties, child, SortPhase.LOCAL_SORT);
- }
-
- /**
- * Constructor of PhysicalLocalQuickSort.
- */
- public PhysicalLocalQuickSort(List<OrderKey> orderKeys,
- Optional<GroupExpression> groupExpression, LogicalProperties
logicalProperties,
- PhysicalProperties physicalProperties, StatsDeriveResult
statsDeriveResult, CHILD_TYPE child) {
- super(PlanType.PHYSICAL_LOCAL_QUICK_SORT, orderKeys, groupExpression,
- logicalProperties, physicalProperties, statsDeriveResult,
child, SortPhase.LOCAL_SORT);
- }
-
- public List<OrderKey> getOrderKeys() {
- return orderKeys;
- }
-
- @Override
- public <R, C> R accept(PlanVisitor<R, C> visitor, C context) {
- return visitor.visitPhysicalLocalQuickSort(this, context);
- }
-
- @Override
- public PhysicalLocalQuickSort<Plan> withChildren(List<Plan> children) {
- Preconditions.checkArgument(children.size() == 1);
- return new PhysicalLocalQuickSort<>(orderKeys, getLogicalProperties(),
children.get(0));
- }
-
- @Override
- public PhysicalLocalQuickSort<CHILD_TYPE>
withGroupExpression(Optional<GroupExpression> groupExpression) {
- return new PhysicalLocalQuickSort<>(orderKeys, groupExpression,
getLogicalProperties(), child());
- }
-
- @Override
- public PhysicalLocalQuickSort<CHILD_TYPE>
withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
- return new PhysicalLocalQuickSort<>(orderKeys, Optional.empty(),
logicalProperties.get(), child());
- }
-
- @Override
- public PhysicalLocalQuickSort<CHILD_TYPE>
withPhysicalPropertiesAndStats(PhysicalProperties physicalProperties,
- StatsDeriveResult statsDeriveResult) {
- return new PhysicalLocalQuickSort<>(orderKeys, Optional.empty(),
- getLogicalProperties(), physicalProperties, statsDeriveResult,
child());
- }
-
- @Override
- public String toString() {
- return Utils.toSqlString("PhysicalLocalQuickSort",
- "orderKeys", orderKeys);
- }
-}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalQuickSort.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalQuickSort.java
index 5f844feedc..383763de77 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalQuickSort.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalQuickSort.java
@@ -44,28 +44,27 @@ import java.util.Optional;
*/
public class PhysicalQuickSort<CHILD_TYPE extends Plan> extends
AbstractPhysicalSort<CHILD_TYPE> implements Sort {
public PhysicalQuickSort(List<OrderKey> orderKeys,
- LogicalProperties logicalProperties, CHILD_TYPE child, SortPhase
phase) {
- this(orderKeys, Optional.empty(), logicalProperties, child, phase);
+ SortPhase phase, LogicalProperties logicalProperties, CHILD_TYPE
child) {
+ this(orderKeys, phase, Optional.empty(), logicalProperties, child);
}
/**
* Constructor of PhysicalHashJoinNode.
*/
public PhysicalQuickSort(List<OrderKey> orderKeys,
- Optional<GroupExpression> groupExpression, LogicalProperties
logicalProperties,
- CHILD_TYPE child, SortPhase phase) {
- super(PlanType.PHYSICAL_QUICK_SORT, orderKeys, groupExpression,
logicalProperties, child, phase);
+ SortPhase phase, Optional<GroupExpression> groupExpression,
LogicalProperties logicalProperties,
+ CHILD_TYPE child) {
+ super(PlanType.PHYSICAL_QUICK_SORT, orderKeys, phase, groupExpression,
logicalProperties, child);
}
/**
* Constructor of PhysicalQuickSort.
*/
public PhysicalQuickSort(List<OrderKey> orderKeys,
- Optional<GroupExpression> groupExpression, LogicalProperties
logicalProperties,
- PhysicalProperties physicalProperties, StatsDeriveResult
statsDeriveResult, CHILD_TYPE child,
- SortPhase phase) {
- super(PlanType.PHYSICAL_QUICK_SORT, orderKeys, groupExpression,
logicalProperties, physicalProperties,
- statsDeriveResult, child, phase);
+ SortPhase phase, Optional<GroupExpression> groupExpression,
LogicalProperties logicalProperties,
+ PhysicalProperties physicalProperties, StatsDeriveResult
statsDeriveResult, CHILD_TYPE child) {
+ super(PlanType.PHYSICAL_QUICK_SORT, orderKeys, phase, groupExpression,
logicalProperties, physicalProperties,
+ statsDeriveResult, child);
}
@Override
@@ -76,24 +75,24 @@ public class PhysicalQuickSort<CHILD_TYPE extends Plan>
extends AbstractPhysical
@Override
public PhysicalQuickSort<Plan> withChildren(List<Plan> children) {
Preconditions.checkArgument(children.size() == 1);
- return new PhysicalQuickSort<>(orderKeys, getLogicalProperties(),
children.get(0), phase);
+ return new PhysicalQuickSort<>(orderKeys, phase,
getLogicalProperties(), children.get(0));
}
@Override
public PhysicalQuickSort<CHILD_TYPE>
withGroupExpression(Optional<GroupExpression> groupExpression) {
- return new PhysicalQuickSort<>(orderKeys, groupExpression,
getLogicalProperties(), child(), phase);
+ return new PhysicalQuickSort<>(orderKeys, phase, groupExpression,
getLogicalProperties(), child());
}
@Override
public PhysicalQuickSort<CHILD_TYPE>
withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
- return new PhysicalQuickSort<>(orderKeys, Optional.empty(),
logicalProperties.get(), child(), phase);
+ return new PhysicalQuickSort<>(orderKeys, phase, Optional.empty(),
logicalProperties.get(), child());
}
@Override
public PhysicalQuickSort<CHILD_TYPE>
withPhysicalPropertiesAndStats(PhysicalProperties physicalProperties,
StatsDeriveResult statsDeriveResult) {
- return new PhysicalQuickSort<>(orderKeys, Optional.empty(),
getLogicalProperties(), physicalProperties,
- statsDeriveResult, child(), phase);
+ return new PhysicalQuickSort<>(orderKeys, phase, Optional.empty(),
getLogicalProperties(), physicalProperties,
+ statsDeriveResult, child());
}
@Override
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalTopN.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalTopN.java
index b79861b3fa..13f52eb103 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalTopN.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalTopN.java
@@ -44,17 +44,17 @@ public class PhysicalTopN<CHILD_TYPE extends Plan> extends
AbstractPhysicalSort<
private final int offset;
public PhysicalTopN(List<OrderKey> orderKeys, int limit, int offset,
- LogicalProperties logicalProperties, CHILD_TYPE child, SortPhase
phase) {
- this(orderKeys, limit, offset, Optional.empty(), logicalProperties,
child, phase);
+ SortPhase phase, LogicalProperties logicalProperties, CHILD_TYPE
child) {
+ this(orderKeys, limit, offset, phase, Optional.empty(),
logicalProperties, child);
}
/**
* Constructor of PhysicalHashJoinNode.
*/
public PhysicalTopN(List<OrderKey> orderKeys, int limit, int offset,
- Optional<GroupExpression> groupExpression, LogicalProperties
logicalProperties,
- CHILD_TYPE child, SortPhase phase) {
- super(PlanType.PHYSICAL_TOP_N, orderKeys, groupExpression,
logicalProperties, child, phase);
+ SortPhase phase, Optional<GroupExpression> groupExpression,
LogicalProperties logicalProperties,
+ CHILD_TYPE child) {
+ super(PlanType.PHYSICAL_TOP_N, orderKeys, phase, groupExpression,
logicalProperties, child);
Objects.requireNonNull(orderKeys, "orderKeys should not be null in
PhysicalTopN.");
this.limit = limit;
this.offset = offset;
@@ -64,11 +64,10 @@ public class PhysicalTopN<CHILD_TYPE extends Plan> extends
AbstractPhysicalSort<
* Constructor of PhysicalHashJoinNode.
*/
public PhysicalTopN(List<OrderKey> orderKeys, int limit, int offset,
- Optional<GroupExpression> groupExpression, LogicalProperties
logicalProperties,
- PhysicalProperties physicalProperties, StatsDeriveResult
statsDeriveResult, CHILD_TYPE child,
- SortPhase phase) {
- super(PlanType.PHYSICAL_TOP_N, orderKeys, groupExpression,
logicalProperties, physicalProperties,
- statsDeriveResult, child, phase);
+ SortPhase phase, Optional<GroupExpression> groupExpression,
LogicalProperties logicalProperties,
+ PhysicalProperties physicalProperties, StatsDeriveResult
statsDeriveResult, CHILD_TYPE child) {
+ super(PlanType.PHYSICAL_TOP_N, orderKeys, phase, groupExpression,
logicalProperties, physicalProperties,
+ statsDeriveResult, child);
Objects.requireNonNull(orderKeys, "orderKeys should not be null in
PhysicalTopN.");
this.limit = limit;
this.offset = offset;
@@ -110,24 +109,24 @@ public class PhysicalTopN<CHILD_TYPE extends Plan>
extends AbstractPhysicalSort<
@Override
public PhysicalTopN<Plan> withChildren(List<Plan> children) {
Preconditions.checkArgument(children.size() == 1);
- return new PhysicalTopN<>(orderKeys, limit, offset,
getLogicalProperties(), children.get(0), phase);
+ return new PhysicalTopN<>(orderKeys, limit, offset, phase,
getLogicalProperties(), children.get(0));
}
@Override
public PhysicalTopN<CHILD_TYPE>
withGroupExpression(Optional<GroupExpression> groupExpression) {
- return new PhysicalTopN<>(orderKeys, limit, offset, groupExpression,
getLogicalProperties(), child(), phase);
+ return new PhysicalTopN<>(orderKeys, limit, offset, phase,
groupExpression, getLogicalProperties(), child());
}
@Override
public PhysicalTopN<CHILD_TYPE>
withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
- return new PhysicalTopN<>(orderKeys, limit, offset, Optional.empty(),
logicalProperties.get(), child(), phase);
+ return new PhysicalTopN<>(orderKeys, limit, offset, phase,
Optional.empty(), logicalProperties.get(), child());
}
@Override
public PhysicalTopN<CHILD_TYPE>
withPhysicalPropertiesAndStats(PhysicalProperties physicalProperties,
StatsDeriveResult statsDeriveResult) {
- return new PhysicalTopN<>(orderKeys, limit, offset, Optional.empty(),
- getLogicalProperties(), physicalProperties, statsDeriveResult,
child(), phase);
+ return new PhysicalTopN<>(orderKeys, limit, offset, phase,
Optional.empty(),
+ getLogicalProperties(), physicalProperties, statsDeriveResult,
child());
}
@Override
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/visitor/PlanVisitor.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/visitor/PlanVisitor.java
index 0723b6444e..cd09c69df5 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/visitor/PlanVisitor.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/visitor/PlanVisitor.java
@@ -66,7 +66,6 @@ import
org.apache.doris.nereids.trees.plans.physical.PhysicalHashAggregate;
import org.apache.doris.nereids.trees.plans.physical.PhysicalHashJoin;
import org.apache.doris.nereids.trees.plans.physical.PhysicalIntersect;
import org.apache.doris.nereids.trees.plans.physical.PhysicalLimit;
-import org.apache.doris.nereids.trees.plans.physical.PhysicalLocalQuickSort;
import org.apache.doris.nereids.trees.plans.physical.PhysicalNestedLoopJoin;
import org.apache.doris.nereids.trees.plans.physical.PhysicalOlapScan;
import org.apache.doris.nereids.trees.plans.physical.PhysicalOneRowRelation;
@@ -354,10 +353,6 @@ public abstract class PlanVisitor<R, C> {
return visit(distribute, context);
}
- public R visitPhysicalLocalQuickSort(PhysicalLocalQuickSort<? extends
Plan> sort, C context) {
- return visitAbstractPhysicalSort(sort, context);
- }
-
public R visitPhysicalAssertNumRows(PhysicalAssertNumRows<? extends Plan>
assertNumRows, C context) {
return visit(assertNumRows, context);
}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriverTest.java
b/fe/fe-core/src/test/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriverTest.java
index a38a659981..9cd2888b38 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriverTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriverTest.java
@@ -40,7 +40,6 @@ import
org.apache.doris.nereids.trees.plans.physical.PhysicalAssertNumRows;
import org.apache.doris.nereids.trees.plans.physical.PhysicalHashAggregate;
import org.apache.doris.nereids.trees.plans.physical.PhysicalHashJoin;
import org.apache.doris.nereids.trees.plans.physical.PhysicalLimit;
-import org.apache.doris.nereids.trees.plans.physical.PhysicalLocalQuickSort;
import org.apache.doris.nereids.trees.plans.physical.PhysicalNestedLoopJoin;
import org.apache.doris.nereids.trees.plans.physical.PhysicalQuickSort;
import org.apache.doris.nereids.trees.plans.physical.PhysicalTopN;
@@ -354,7 +353,7 @@ public class ChildOutputPropertyDeriverTest {
public void testLocalQuickSort() {
SlotReference key = new SlotReference("col1", IntegerType.INSTANCE);
List<OrderKey> orderKeys = Lists.newArrayList(new OrderKey(key, true,
true));
- PhysicalLocalQuickSort<GroupPlan> sort = new
PhysicalLocalQuickSort(orderKeys, logicalProperties, groupPlan);
+ PhysicalQuickSort<GroupPlan> sort = new PhysicalQuickSort(orderKeys,
SortPhase.LOCAL_SORT, logicalProperties, groupPlan);
GroupExpression groupExpression = new GroupExpression(sort);
PhysicalProperties child = new
PhysicalProperties(DistributionSpecReplicated.INSTANCE,
new OrderSpec(Lists.newArrayList(
@@ -370,7 +369,7 @@ public class ChildOutputPropertyDeriverTest {
public void testQuickSort() {
SlotReference key = new SlotReference("col1", IntegerType.INSTANCE);
List<OrderKey> orderKeys = Lists.newArrayList(new OrderKey(key, true,
true));
- PhysicalQuickSort<GroupPlan> sort = new PhysicalQuickSort<>(orderKeys,
logicalProperties, groupPlan, SortPhase.MERGE_SORT);
+ PhysicalQuickSort<GroupPlan> sort = new PhysicalQuickSort<>(orderKeys,
SortPhase.MERGE_SORT, logicalProperties, groupPlan);
GroupExpression groupExpression = new GroupExpression(sort);
PhysicalProperties child = new
PhysicalProperties(DistributionSpecReplicated.INSTANCE,
new OrderSpec(Lists.newArrayList(
@@ -386,7 +385,7 @@ public class ChildOutputPropertyDeriverTest {
public void testTopN() {
SlotReference key = new SlotReference("col1", IntegerType.INSTANCE);
List<OrderKey> orderKeys = Lists.newArrayList(new OrderKey(key, true,
true));
- PhysicalTopN<GroupPlan> sort = new PhysicalTopN<>(orderKeys, 10, 10,
logicalProperties, groupPlan, SortPhase.LOCAL_SORT);
+ PhysicalTopN<GroupPlan> sort = new PhysicalTopN<>(orderKeys, 10, 10,
SortPhase.LOCAL_SORT, logicalProperties, groupPlan);
GroupExpression groupExpression = new GroupExpression(sort);
PhysicalProperties child = new
PhysicalProperties(DistributionSpecReplicated.INSTANCE,
new OrderSpec(Lists.newArrayList(
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/PlanEqualsTest.java
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/PlanEqualsTest.java
index 0913b6af23..09048737a4 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/PlanEqualsTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/PlanEqualsTest.java
@@ -309,23 +309,23 @@ public class PlanEqualsTest {
ImmutableList.of(new OrderKey(
new SlotReference(new ExprId(1), "b",
BigIntType.INSTANCE, true, Lists.newArrayList()), true,
true)),
- logicalProperties,
- child, SortPhase.LOCAL_SORT);
+ SortPhase.LOCAL_SORT, logicalProperties,
+ child);
PhysicalQuickSort<Plan> expected = new PhysicalQuickSort<>(
ImmutableList.of(new OrderKey(
new SlotReference(new ExprId(1), "b",
BigIntType.INSTANCE, true, Lists.newArrayList()), true,
true)),
- logicalProperties,
- child, SortPhase.LOCAL_SORT);
+ SortPhase.LOCAL_SORT, logicalProperties,
+ child);
Assertions.assertEquals(expected, actual);
PhysicalQuickSort<Plan> unexpected = new PhysicalQuickSort<>(
ImmutableList.of(new OrderKey(
new SlotReference(new ExprId(2), "a",
BigIntType.INSTANCE, true, Lists.newArrayList()), true,
true)),
- logicalProperties,
- child, SortPhase.LOCAL_SORT);
+ SortPhase.LOCAL_SORT, logicalProperties,
+ child);
Assertions.assertNotEquals(unexpected, actual);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]