[refactor](Nereids) remove local sort (#16819)

After adding phase in sort, the locatSort is no longer needed
change the order of sortPhase in constructor
This commit is contained in:
谢健
2023-02-17 18:52:41 +08:00
committed by GitHub
parent 9b94729c87
commit fd5d7d6097
16 changed files with 54 additions and 226 deletions

View File

@ -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) {

View File

@ -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:

View File

@ -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);

View File

@ -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);

View File

@ -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)
);
}

View File

@ -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();

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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) {

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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

View File

@ -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

View File

@ -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);
}

View File

@ -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(

View File

@ -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);
}
}