[enhancement](Nereids): use ImmutableList explicitly in Plan (#13817)
This commit is contained in:
@ -41,7 +41,7 @@ import java.util.stream.Collectors;
|
||||
* <p>
|
||||
* Use the correlated column as the group by column of agg,
|
||||
* the output column is the correlated column and the input column.
|
||||
* <p>
|
||||
* <pre>
|
||||
* before:
|
||||
* apply
|
||||
* / \
|
||||
@ -55,6 +55,7 @@ import java.util.stream.Collectors;
|
||||
* Input(output:b) agg(output:fn,this.f; group by:this.f)
|
||||
* |
|
||||
* Filter(Uncorrelated predicate)
|
||||
* </pre>
|
||||
*/
|
||||
public class ApplyPullFilterOnAgg extends OneRewriteRuleFactory {
|
||||
@Override
|
||||
|
||||
@ -33,6 +33,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* Swap the order of project and filter under agg in correlated subqueries.
|
||||
* <pre>
|
||||
* before:
|
||||
* apply
|
||||
* / \
|
||||
@ -54,6 +55,7 @@ import java.util.List;
|
||||
* Project(output:a,this.f, Unapply predicate(slots))
|
||||
* |
|
||||
* child
|
||||
* </pre>
|
||||
*/
|
||||
public class ApplyPullFilterOnProjectUnderAgg extends OneRewriteRuleFactory {
|
||||
@Override
|
||||
@ -66,12 +68,11 @@ public class ApplyPullFilterOnProjectUnderAgg extends OneRewriteRuleFactory {
|
||||
LogicalFilter<GroupPlan> filter = project.child();
|
||||
List<NamedExpression> newProjects = Lists.newArrayList();
|
||||
newProjects.addAll(project.getProjects());
|
||||
filter.child().getOutput()
|
||||
.stream().forEach(slot -> {
|
||||
if (!newProjects.contains(slot)) {
|
||||
newProjects.add(slot);
|
||||
}
|
||||
});
|
||||
filter.child().getOutput().forEach(slot -> {
|
||||
if (!newProjects.contains(slot)) {
|
||||
newProjects.add(slot);
|
||||
}
|
||||
});
|
||||
|
||||
LogicalProject newProject = new LogicalProject<>(newProjects, filter.child());
|
||||
LogicalFilter newFilter = new LogicalFilter<>(filter.getPredicates(), newProject);
|
||||
|
||||
@ -44,21 +44,21 @@ import java.util.stream.Collectors;
|
||||
* normalize aggregate's group keys and AggregateFunction's child to SlotReference
|
||||
* and generate a LogicalProject top on LogicalAggregate to hold to order of aggregate output,
|
||||
* since aggregate output's order could change when we do translate.
|
||||
*
|
||||
* <p>
|
||||
* Apply this rule could simplify the processing of enforce and translate.
|
||||
*
|
||||
* <pre>
|
||||
* Original Plan:
|
||||
* Aggregate(
|
||||
* keys:[k1#1, K2#2 + 1],
|
||||
* outputs:[k1#1, Alias(K2# + 1)#4, Alias(k1#1 + 1)#5, Alias(SUM(v1#3))#6,
|
||||
* Alias(SUM(v1#3 + 1))#7, Alias(SUM(v1#3) + 1)#8])
|
||||
*
|
||||
* </pre>
|
||||
* After rule:
|
||||
* Project(k1#1, Alias(SR#9)#4, Alias(k1#1 + 1)#5, Alias(SR#10))#6, Alias(SR#11))#7, Alias(SR#10 + 1)#8)
|
||||
* +-- Aggregate(keys:[k1#1, SR#9], outputs:[k1#1, SR#9, Alias(SUM(v1#3))#10, Alias(SUM(v1#3 + 1))#11])
|
||||
* +-- Project(k1#1, Alias(K2#2 + 1)#9, v1#3)
|
||||
*
|
||||
* More example could get from UT {@link NormalizeAggregateTest}
|
||||
* +-- Project(k1#1, Alias(K2#2 + 1)#9, v1#3)
|
||||
* <p>
|
||||
* More example could get from UT {NormalizeAggregateTest}
|
||||
*/
|
||||
public class NormalizeAggregate extends OneRewriteRuleFactory {
|
||||
@Override
|
||||
|
||||
@ -56,10 +56,10 @@ public class LogicalAggregate<CHILD_TYPE extends Plan> extends LogicalUnary<CHIL
|
||||
private final boolean disassembled;
|
||||
private final boolean normalized;
|
||||
private final AggPhase aggPhase;
|
||||
private final List<Expression> groupByExpressions;
|
||||
private final List<NamedExpression> outputExpressions;
|
||||
private final ImmutableList<Expression> groupByExpressions;
|
||||
private final ImmutableList<NamedExpression> outputExpressions;
|
||||
// TODO: we should decide partition expression according to cost.
|
||||
private final Optional<List<Expression>> partitionExpressions;
|
||||
private final Optional<ImmutableList<Expression>> partitionExpressions;
|
||||
|
||||
// use for scenes containing distinct agg
|
||||
// 1. If there is LOCAL only, LOCAL is the final phase
|
||||
@ -121,7 +121,7 @@ public class LogicalAggregate<CHILD_TYPE extends Plan> extends LogicalUnary<CHIL
|
||||
super(PlanType.LOGICAL_AGGREGATE, groupExpression, logicalProperties, child);
|
||||
this.groupByExpressions = ImmutableList.copyOf(groupByExpressions);
|
||||
this.outputExpressions = ImmutableList.copyOf(outputExpressions);
|
||||
this.partitionExpressions = partitionExpressions;
|
||||
this.partitionExpressions = partitionExpressions.map(ImmutableList::copyOf);
|
||||
this.disassembled = disassembled;
|
||||
this.normalized = normalized;
|
||||
this.isFinalPhase = isFinalPhase;
|
||||
@ -214,27 +214,27 @@ public class LogicalAggregate<CHILD_TYPE extends Plan> extends LogicalUnary<CHIL
|
||||
@Override
|
||||
public LogicalAggregate<Plan> withChildren(List<Plan> children) {
|
||||
Preconditions.checkArgument(children.size() == 1);
|
||||
return new LogicalAggregate<>(groupByExpressions, outputExpressions, partitionExpressions,
|
||||
return new LogicalAggregate<>(groupByExpressions, outputExpressions, partitionExpressions.map(List.class::cast),
|
||||
disassembled, normalized, isFinalPhase, aggPhase, children.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public LogicalAggregate<Plan> withGroupExpression(Optional<GroupExpression> groupExpression) {
|
||||
return new LogicalAggregate<>(groupByExpressions, outputExpressions, partitionExpressions,
|
||||
return new LogicalAggregate<>(groupByExpressions, outputExpressions, partitionExpressions.map(List.class::cast),
|
||||
disassembled, normalized, isFinalPhase, aggPhase,
|
||||
groupExpression, Optional.of(getLogicalProperties()), children.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public LogicalAggregate<Plan> withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
|
||||
return new LogicalAggregate<>(groupByExpressions, outputExpressions, partitionExpressions,
|
||||
return new LogicalAggregate<>(groupByExpressions, outputExpressions, partitionExpressions.map(List.class::cast),
|
||||
disassembled, normalized, isFinalPhase, aggPhase,
|
||||
Optional.empty(), logicalProperties, children.get(0));
|
||||
}
|
||||
|
||||
public LogicalAggregate<Plan> withGroupByAndOutput(List<Expression> groupByExprList,
|
||||
List<NamedExpression> outputExpressionList) {
|
||||
return new LogicalAggregate<>(groupByExprList, outputExpressionList, partitionExpressions,
|
||||
return new LogicalAggregate<>(groupByExprList, outputExpressionList, partitionExpressions.map(List.class::cast),
|
||||
disassembled, normalized, isFinalPhase, aggPhase, child());
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ import java.util.Optional;
|
||||
public class LogicalApply<LEFT_CHILD_TYPE extends Plan, RIGHT_CHILD_TYPE extends Plan>
|
||||
extends LogicalBinary<LEFT_CHILD_TYPE, RIGHT_CHILD_TYPE> {
|
||||
// correlation column
|
||||
private final List<Expression> correlationSlot;
|
||||
private final ImmutableList<Expression> correlationSlot;
|
||||
// original subquery
|
||||
private final SubqueryExpr subqueryExpr;
|
||||
// correlation Conjunction
|
||||
|
||||
@ -40,7 +40,7 @@ import java.util.Optional;
|
||||
* select * from tbl limit 0
|
||||
*/
|
||||
public class LogicalEmptyRelation extends LogicalLeaf implements EmptyRelation {
|
||||
private final List<? extends NamedExpression> projects;
|
||||
private final ImmutableList<? extends NamedExpression> projects;
|
||||
|
||||
public LogicalEmptyRelation(List<? extends NamedExpression> projects) {
|
||||
this(projects, Optional.empty(), Optional.empty());
|
||||
|
||||
@ -45,8 +45,8 @@ import java.util.stream.Collectors;
|
||||
public class LogicalJoin<LEFT_CHILD_TYPE extends Plan, RIGHT_CHILD_TYPE extends Plan>
|
||||
extends LogicalBinary<LEFT_CHILD_TYPE, RIGHT_CHILD_TYPE> implements Join {
|
||||
private final JoinType joinType;
|
||||
private final List<Expression> otherJoinConjuncts;
|
||||
private final List<Expression> hashJoinConjuncts;
|
||||
private final ImmutableList<Expression> otherJoinConjuncts;
|
||||
private final ImmutableList<Expression> hashJoinConjuncts;
|
||||
|
||||
// Use for top-to-down join reorder
|
||||
private final JoinReorderContext joinReorderContext = new JoinReorderContext();
|
||||
@ -105,8 +105,8 @@ public class LogicalJoin<LEFT_CHILD_TYPE extends Plan, RIGHT_CHILD_TYPE extends
|
||||
LEFT_CHILD_TYPE leftChild, RIGHT_CHILD_TYPE rightChild) {
|
||||
super(PlanType.LOGICAL_JOIN, groupExpression, logicalProperties, leftChild, rightChild);
|
||||
this.joinType = Objects.requireNonNull(joinType, "joinType can not be null");
|
||||
this.hashJoinConjuncts = hashJoinConjuncts;
|
||||
this.otherJoinConjuncts = Objects.requireNonNull(otherJoinConjuncts, "condition can not be null");
|
||||
this.hashJoinConjuncts = ImmutableList.copyOf(hashJoinConjuncts);
|
||||
this.otherJoinConjuncts = ImmutableList.copyOf(otherJoinConjuncts);
|
||||
}
|
||||
|
||||
public List<Expression> getOtherJoinConjuncts() {
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
package org.apache.doris.nereids.trees.plans.logical;
|
||||
|
||||
import org.apache.doris.catalog.OlapTable;
|
||||
import org.apache.doris.catalog.Partition;
|
||||
import org.apache.doris.catalog.Table;
|
||||
import org.apache.doris.nereids.memo.GroupExpression;
|
||||
import org.apache.doris.nereids.properties.LogicalProperties;
|
||||
@ -32,7 +31,6 @@ import org.apache.doris.nereids.util.Utils;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
@ -45,10 +43,10 @@ import java.util.Optional;
|
||||
public class LogicalOlapScan extends LogicalRelation {
|
||||
|
||||
private final long selectedIndexId;
|
||||
private final List<Long> selectedTabletId;
|
||||
private final ImmutableList<Long> selectedTabletId;
|
||||
private final boolean partitionPruned;
|
||||
|
||||
private final List<Long> candidateIndexIds;
|
||||
private final ImmutableList<Long> candidateIndexIds;
|
||||
private final boolean indexSelected;
|
||||
|
||||
private final PreAggStatus preAggStatus;
|
||||
@ -80,12 +78,11 @@ public class LogicalOlapScan extends LogicalRelation {
|
||||
// revisit this after rollup and materialized view selection are fully supported.
|
||||
this.selectedIndexId = CollectionUtils.isEmpty(candidateIndexIds)
|
||||
? getTable().getBaseIndexId() : candidateIndexIds.get(0);
|
||||
this.selectedTabletId = Lists.newArrayList();
|
||||
for (Partition partition : getTable().getAllPartitions()) {
|
||||
selectedTabletId.addAll(partition.getBaseIndex().getTabletIdsInOrder());
|
||||
}
|
||||
this.selectedTabletId = getTable().getAllPartitions().stream()
|
||||
.flatMap(partition -> partition.getBaseIndex().getTabletIdsInOrder().stream())
|
||||
.collect(ImmutableList.toImmutableList());
|
||||
this.partitionPruned = partitionPruned;
|
||||
this.candidateIndexIds = candidateIndexIds;
|
||||
this.candidateIndexIds = ImmutableList.copyOf(candidateIndexIds);
|
||||
this.indexSelected = indexSelected;
|
||||
this.preAggStatus = preAggStatus;
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ import java.util.Optional;
|
||||
* e.g. select 100, 'value'
|
||||
*/
|
||||
public class LogicalOneRowRelation extends LogicalLeaf implements OneRowRelation {
|
||||
private final List<NamedExpression> projects;
|
||||
private final ImmutableList<NamedExpression> projects;
|
||||
|
||||
public LogicalOneRowRelation(List<NamedExpression> projects) {
|
||||
this(projects, Optional.empty(), Optional.empty());
|
||||
|
||||
@ -40,7 +40,7 @@ import java.util.Optional;
|
||||
*/
|
||||
public class LogicalProject<CHILD_TYPE extends Plan> extends LogicalUnary<CHILD_TYPE> implements Project {
|
||||
|
||||
private final List<NamedExpression> projects;
|
||||
private final ImmutableList<NamedExpression> projects;
|
||||
|
||||
public LogicalProject(List<NamedExpression> projects, CHILD_TYPE child) {
|
||||
this(projects, Optional.empty(), Optional.empty(), child);
|
||||
|
||||
@ -42,8 +42,8 @@ import java.util.Optional;
|
||||
public abstract class LogicalRelation extends LogicalLeaf implements Scan {
|
||||
|
||||
protected final Table table;
|
||||
protected final List<String> qualifier;
|
||||
protected final List<Long> selectedPartitionIds;
|
||||
protected final ImmutableList<String> qualifier;
|
||||
protected final ImmutableList<Long> selectedPartitionIds;
|
||||
|
||||
protected final RelationId id;
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ import java.util.stream.Collectors;
|
||||
* e.g. LogicalSelectHint (set_var(query_timeout='1800', exec_mem_limit='2147483648'))
|
||||
*/
|
||||
public class LogicalSelectHint<CHILD_TYPE extends Plan> extends LogicalUnary<CHILD_TYPE> {
|
||||
private final Map<String, SelectHint> hints;
|
||||
private final ImmutableMap<String, SelectHint> hints;
|
||||
|
||||
public LogicalSelectHint(Map<String, SelectHint> hints, CHILD_TYPE child) {
|
||||
this(hints, Optional.empty(), Optional.empty(), child);
|
||||
|
||||
@ -44,7 +44,7 @@ import java.util.Optional;
|
||||
*/
|
||||
public class LogicalSort<CHILD_TYPE extends Plan> extends LogicalUnary<CHILD_TYPE> implements Sort {
|
||||
|
||||
private final List<OrderKey> orderKeys;
|
||||
private final ImmutableList<OrderKey> orderKeys;
|
||||
|
||||
public LogicalSort(List<OrderKey> orderKeys, CHILD_TYPE child) {
|
||||
this(orderKeys, Optional.empty(), Optional.empty(), child);
|
||||
@ -56,7 +56,7 @@ public class LogicalSort<CHILD_TYPE extends Plan> extends LogicalUnary<CHILD_TYP
|
||||
public LogicalSort(List<OrderKey> orderKeys, Optional<GroupExpression> groupExpression,
|
||||
Optional<LogicalProperties> logicalProperties, CHILD_TYPE child) {
|
||||
super(PlanType.LOGICAL_SORT, groupExpression, logicalProperties, child);
|
||||
this.orderKeys = Objects.requireNonNull(orderKeys, "orderKeys can not be null");
|
||||
this.orderKeys = ImmutableList.copyOf(Objects.requireNonNull(orderKeys, "orderKeys can not be null"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -40,7 +40,7 @@ import java.util.Optional;
|
||||
*/
|
||||
public class LogicalTopN<CHILD_TYPE extends Plan> extends LogicalUnary<CHILD_TYPE> implements TopN {
|
||||
|
||||
private final List<OrderKey> orderKeys;
|
||||
private final ImmutableList<OrderKey> orderKeys;
|
||||
private final int limit;
|
||||
private final int offset;
|
||||
|
||||
@ -54,7 +54,7 @@ public class LogicalTopN<CHILD_TYPE extends Plan> extends LogicalUnary<CHILD_TYP
|
||||
public LogicalTopN(List<OrderKey> orderKeys, int limit, int offset, Optional<GroupExpression> groupExpression,
|
||||
Optional<LogicalProperties> logicalProperties, CHILD_TYPE child) {
|
||||
super(PlanType.LOGICAL_TOP_N, groupExpression, logicalProperties, child);
|
||||
this.orderKeys = Objects.requireNonNull(orderKeys, "orderKeys can not be null");
|
||||
this.orderKeys = ImmutableList.copyOf(Objects.requireNonNull(orderKeys, "orderKeys can not be null"));
|
||||
this.limit = limit;
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
@ -28,6 +28,7 @@ import org.apache.doris.nereids.trees.plans.algebra.Join;
|
||||
import org.apache.doris.nereids.util.ExpressionUtils;
|
||||
import org.apache.doris.statistics.StatsDeriveResult;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableList.Builder;
|
||||
|
||||
import java.util.List;
|
||||
@ -43,9 +44,9 @@ public abstract class AbstractPhysicalJoin<
|
||||
extends PhysicalBinary<LEFT_CHILD_TYPE, RIGHT_CHILD_TYPE> implements Join {
|
||||
protected final JoinType joinType;
|
||||
|
||||
protected final List<Expression> hashJoinConjuncts;
|
||||
protected final ImmutableList<Expression> hashJoinConjuncts;
|
||||
|
||||
protected final List<Expression> otherJoinConjuncts;
|
||||
protected final ImmutableList<Expression> otherJoinConjuncts;
|
||||
|
||||
/**
|
||||
* Constructor of PhysicalJoin.
|
||||
@ -55,8 +56,8 @@ public abstract class AbstractPhysicalJoin<
|
||||
LogicalProperties logicalProperties, LEFT_CHILD_TYPE leftChild, RIGHT_CHILD_TYPE rightChild) {
|
||||
super(type, groupExpression, logicalProperties, leftChild, rightChild);
|
||||
this.joinType = Objects.requireNonNull(joinType, "joinType can not be null");
|
||||
this.hashJoinConjuncts = hashJoinConjuncts;
|
||||
this.otherJoinConjuncts = Objects.requireNonNull(otherJoinConjuncts, "condition can not be null");
|
||||
this.hashJoinConjuncts = ImmutableList.copyOf(hashJoinConjuncts);
|
||||
this.otherJoinConjuncts = ImmutableList.copyOf(otherJoinConjuncts);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -68,8 +69,8 @@ public abstract class AbstractPhysicalJoin<
|
||||
StatsDeriveResult statsDeriveResult, LEFT_CHILD_TYPE leftChild, RIGHT_CHILD_TYPE rightChild) {
|
||||
super(type, groupExpression, logicalProperties, physicalProperties, statsDeriveResult, leftChild, rightChild);
|
||||
this.joinType = Objects.requireNonNull(joinType, "joinType can not be null");
|
||||
this.hashJoinConjuncts = hashJoinConjuncts;
|
||||
this.otherJoinConjuncts = Objects.requireNonNull(otherJoinConjuncts, "condition can not be null");
|
||||
this.hashJoinConjuncts = ImmutableList.copyOf(hashJoinConjuncts);
|
||||
this.otherJoinConjuncts = ImmutableList.copyOf(otherJoinConjuncts);
|
||||
}
|
||||
|
||||
public List<Expression> getHashJoinConjuncts() {
|
||||
|
||||
@ -38,7 +38,7 @@ import java.util.Optional;
|
||||
*/
|
||||
public abstract class AbstractPhysicalSort<CHILD_TYPE extends Plan> extends PhysicalUnary<CHILD_TYPE> implements Sort {
|
||||
|
||||
protected final List<OrderKey> orderKeys;
|
||||
protected final ImmutableList<OrderKey> orderKeys;
|
||||
|
||||
/**
|
||||
* Constructor of AbstractPhysicalSort.
|
||||
|
||||
@ -43,11 +43,11 @@ import java.util.Optional;
|
||||
*/
|
||||
public class PhysicalAggregate<CHILD_TYPE extends Plan> extends PhysicalUnary<CHILD_TYPE> implements Aggregate {
|
||||
|
||||
private final List<Expression> groupByExpressions;
|
||||
private final ImmutableList<Expression> groupByExpressions;
|
||||
|
||||
private final List<NamedExpression> outputExpressions;
|
||||
private final ImmutableList<NamedExpression> outputExpressions;
|
||||
|
||||
private final List<Expression> partitionExpressions;
|
||||
private final ImmutableList<Expression> partitionExpressions;
|
||||
|
||||
private final AggPhase aggPhase;
|
||||
|
||||
@ -80,10 +80,10 @@ public class PhysicalAggregate<CHILD_TYPE extends Plan> extends PhysicalUnary<CH
|
||||
Optional<GroupExpression> groupExpression, LogicalProperties logicalProperties,
|
||||
CHILD_TYPE child) {
|
||||
super(PlanType.PHYSICAL_AGGREGATE, groupExpression, logicalProperties, child);
|
||||
this.groupByExpressions = groupByExpressions;
|
||||
this.outputExpressions = outputExpressions;
|
||||
this.groupByExpressions = ImmutableList.copyOf(groupByExpressions);
|
||||
this.outputExpressions = ImmutableList.copyOf(outputExpressions);
|
||||
this.aggPhase = aggPhase;
|
||||
this.partitionExpressions = partitionExpressions;
|
||||
this.partitionExpressions = ImmutableList.copyOf(partitionExpressions);
|
||||
this.usingStream = usingStream;
|
||||
this.isFinalPhase = isFinalPhase;
|
||||
}
|
||||
@ -102,10 +102,10 @@ public class PhysicalAggregate<CHILD_TYPE extends Plan> extends PhysicalUnary<CH
|
||||
PhysicalProperties physicalProperties, StatsDeriveResult statsDeriveResult, CHILD_TYPE child) {
|
||||
super(PlanType.PHYSICAL_AGGREGATE, groupExpression, logicalProperties, physicalProperties, statsDeriveResult,
|
||||
child);
|
||||
this.groupByExpressions = groupByExpressions;
|
||||
this.outputExpressions = outputExpressions;
|
||||
this.groupByExpressions = ImmutableList.copyOf(groupByExpressions);
|
||||
this.outputExpressions = ImmutableList.copyOf(outputExpressions);
|
||||
this.aggPhase = aggPhase;
|
||||
this.partitionExpressions = partitionExpressions;
|
||||
this.partitionExpressions = ImmutableList.copyOf(partitionExpressions);
|
||||
this.usingStream = usingStream;
|
||||
this.isFinalPhase = isFinalPhase;
|
||||
}
|
||||
|
||||
@ -36,12 +36,6 @@ public abstract class PhysicalBinary<
|
||||
RIGHT_CHILD_TYPE extends Plan>
|
||||
extends AbstractPhysicalPlan
|
||||
implements BinaryPlan<LEFT_CHILD_TYPE, RIGHT_CHILD_TYPE> {
|
||||
|
||||
public PhysicalBinary(PlanType type, LogicalProperties logicalProperties,
|
||||
LEFT_CHILD_TYPE leftChild, RIGHT_CHILD_TYPE rightChild) {
|
||||
super(type, logicalProperties, leftChild, rightChild);
|
||||
}
|
||||
|
||||
public PhysicalBinary(PlanType type, Optional<GroupExpression> groupExpression,
|
||||
LogicalProperties logicalProperties, LEFT_CHILD_TYPE leftChild,
|
||||
RIGHT_CHILD_TYPE rightChild) {
|
||||
|
||||
@ -42,7 +42,7 @@ import java.util.Optional;
|
||||
* select * from tbl limit 0
|
||||
*/
|
||||
public class PhysicalEmptyRelation extends PhysicalLeaf implements EmptyRelation {
|
||||
private final List<? extends NamedExpression> projects;
|
||||
private final ImmutableList<? extends NamedExpression> projects;
|
||||
|
||||
public PhysicalEmptyRelation(List<? extends NamedExpression> projects, LogicalProperties logicalProperties) {
|
||||
this(projects, Optional.empty(), logicalProperties, null, null);
|
||||
|
||||
@ -44,6 +44,7 @@ public class PhysicalHashJoin<
|
||||
|
||||
private boolean shouldTranslateOutput = true;
|
||||
|
||||
// TODO: What's purpose? it's alway empty.
|
||||
private final List<Expression> filterConjuncts = Lists.newArrayList();
|
||||
|
||||
public PhysicalHashJoin(JoinType joinType, List<Expression> hashJoinConjuncts,
|
||||
|
||||
@ -31,11 +31,6 @@ import javax.annotation.Nullable;
|
||||
* Abstract class for all physical plan that have no child.
|
||||
*/
|
||||
public abstract class PhysicalLeaf extends AbstractPhysicalPlan implements LeafPlan {
|
||||
|
||||
public PhysicalLeaf(PlanType type, LogicalProperties logicalProperties) {
|
||||
super(type, logicalProperties);
|
||||
}
|
||||
|
||||
public PhysicalLeaf(PlanType type, Optional<GroupExpression> groupExpression, LogicalProperties logicalProperties) {
|
||||
super(type, groupExpression, logicalProperties);
|
||||
}
|
||||
|
||||
@ -29,6 +29,8 @@ 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.collect.ImmutableList;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
@ -40,8 +42,8 @@ public class PhysicalOlapScan extends PhysicalRelation {
|
||||
private final OlapTable olapTable;
|
||||
private final DistributionSpec distributionSpec;
|
||||
private final long selectedIndexId;
|
||||
private final List<Long> selectedTabletIds;
|
||||
private final List<Long> selectedPartitionIds;
|
||||
private final ImmutableList<Long> selectedTabletIds;
|
||||
private final ImmutableList<Long> selectedPartitionIds;
|
||||
private final PreAggStatus preAggStatus;
|
||||
|
||||
/**
|
||||
@ -53,8 +55,8 @@ public class PhysicalOlapScan extends PhysicalRelation {
|
||||
super(id, PlanType.PHYSICAL_OLAP_SCAN, qualifier, groupExpression, logicalProperties);
|
||||
this.olapTable = olapTable;
|
||||
this.selectedIndexId = selectedIndexId;
|
||||
this.selectedTabletIds = selectedTabletIds;
|
||||
this.selectedPartitionIds = selectedPartitionIds;
|
||||
this.selectedTabletIds = ImmutableList.copyOf(selectedTabletIds);
|
||||
this.selectedPartitionIds = ImmutableList.copyOf(selectedPartitionIds);
|
||||
this.distributionSpec = distributionSpec;
|
||||
this.preAggStatus = preAggStatus;
|
||||
}
|
||||
@ -63,15 +65,15 @@ public class PhysicalOlapScan extends PhysicalRelation {
|
||||
* Constructor for PhysicalOlapScan.
|
||||
*/
|
||||
public PhysicalOlapScan(RelationId id, OlapTable olapTable, List<String> qualifier, long selectedIndexId,
|
||||
List<Long> selectedTabletId, List<Long> selectedPartitionId, DistributionSpec distributionSpec,
|
||||
List<Long> selectedTabletIds, List<Long> selectedPartitionIds, DistributionSpec distributionSpec,
|
||||
PreAggStatus preAggStatus, Optional<GroupExpression> groupExpression, LogicalProperties logicalProperties,
|
||||
PhysicalProperties physicalProperties, StatsDeriveResult statsDeriveResult) {
|
||||
super(id, PlanType.PHYSICAL_OLAP_SCAN, qualifier, groupExpression, logicalProperties, physicalProperties,
|
||||
statsDeriveResult);
|
||||
this.olapTable = olapTable;
|
||||
this.selectedIndexId = selectedIndexId;
|
||||
this.selectedTabletIds = selectedTabletId;
|
||||
this.selectedPartitionIds = selectedPartitionId;
|
||||
this.selectedTabletIds = ImmutableList.copyOf(selectedTabletIds);
|
||||
this.selectedPartitionIds = ImmutableList.copyOf(selectedPartitionIds);
|
||||
this.distributionSpec = distributionSpec;
|
||||
this.preAggStatus = preAggStatus;
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ import java.util.Optional;
|
||||
* e.g. select 100, 'value'
|
||||
*/
|
||||
public class PhysicalOneRowRelation extends PhysicalLeaf implements OneRowRelation {
|
||||
private final List<NamedExpression> projects;
|
||||
private final ImmutableList<NamedExpression> projects;
|
||||
|
||||
public PhysicalOneRowRelation(List<NamedExpression> projects, LogicalProperties logicalProperties) {
|
||||
this(projects, Optional.empty(), logicalProperties, null, null);
|
||||
|
||||
@ -30,6 +30,7 @@ import org.apache.doris.nereids.util.Utils;
|
||||
import org.apache.doris.statistics.StatsDeriveResult;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@ -40,7 +41,7 @@ import java.util.Optional;
|
||||
*/
|
||||
public class PhysicalProject<CHILD_TYPE extends Plan> extends PhysicalUnary<CHILD_TYPE> implements Project {
|
||||
|
||||
private final List<NamedExpression> projects;
|
||||
private final ImmutableList<NamedExpression> projects;
|
||||
|
||||
public PhysicalProject(List<NamedExpression> projects, LogicalProperties logicalProperties, CHILD_TYPE child) {
|
||||
this(projects, Optional.empty(), logicalProperties, child);
|
||||
@ -49,7 +50,7 @@ public class PhysicalProject<CHILD_TYPE extends Plan> extends PhysicalUnary<CHIL
|
||||
public PhysicalProject(List<NamedExpression> projects, Optional<GroupExpression> groupExpression,
|
||||
LogicalProperties logicalProperties, CHILD_TYPE child) {
|
||||
super(PlanType.PHYSICAL_PROJECT, groupExpression, logicalProperties, child);
|
||||
this.projects = Objects.requireNonNull(projects, "projects can not be null");
|
||||
this.projects = ImmutableList.copyOf(Objects.requireNonNull(projects, "projects can not be null"));
|
||||
}
|
||||
|
||||
public PhysicalProject(List<NamedExpression> projects, Optional<GroupExpression> groupExpression,
|
||||
@ -57,7 +58,7 @@ public class PhysicalProject<CHILD_TYPE extends Plan> extends PhysicalUnary<CHIL
|
||||
StatsDeriveResult statsDeriveResult, CHILD_TYPE child) {
|
||||
super(PlanType.PHYSICAL_PROJECT, groupExpression, logicalProperties, physicalProperties, statsDeriveResult,
|
||||
child);
|
||||
this.projects = Objects.requireNonNull(projects, "projects can not be null");
|
||||
this.projects = ImmutableList.copyOf(Objects.requireNonNull(projects, "projects can not be null"));
|
||||
}
|
||||
|
||||
public List<NamedExpression> getProjects() {
|
||||
|
||||
@ -38,7 +38,7 @@ import java.util.Optional;
|
||||
*/
|
||||
public abstract class PhysicalRelation extends PhysicalLeaf implements Scan {
|
||||
|
||||
protected final List<String> qualifier;
|
||||
protected final ImmutableList<String> qualifier;
|
||||
|
||||
protected final RelationId id;
|
||||
|
||||
@ -48,7 +48,7 @@ public abstract class PhysicalRelation extends PhysicalLeaf implements Scan {
|
||||
public PhysicalRelation(RelationId id, PlanType type, List<String> qualifier,
|
||||
Optional<GroupExpression> groupExpression, LogicalProperties logicalProperties) {
|
||||
super(type, groupExpression, logicalProperties);
|
||||
this.qualifier = Objects.requireNonNull(qualifier, "qualifier can not be null");
|
||||
this.qualifier = ImmutableList.copyOf(Objects.requireNonNull(qualifier, "qualifier can not be null"));
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ public abstract class PhysicalRelation extends PhysicalLeaf implements Scan {
|
||||
Optional<GroupExpression> groupExpression, LogicalProperties logicalProperties,
|
||||
PhysicalProperties physicalProperties, StatsDeriveResult statsDeriveResult) {
|
||||
super(type, groupExpression, logicalProperties, physicalProperties, statsDeriveResult);
|
||||
this.qualifier = Objects.requireNonNull(qualifier, "qualifier can not be null");
|
||||
this.qualifier = ImmutableList.copyOf(Objects.requireNonNull(qualifier, "qualifier can not be null"));
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@ -82,8 +82,8 @@ public class RuntimeFilter {
|
||||
if (!expr.children().stream().allMatch(SlotReference.class::isInstance)) {
|
||||
return null;
|
||||
}
|
||||
//current we assume that there are certainly different slot reference in equal to.
|
||||
//they are not from the same relation.
|
||||
// current we assume that there are certainly different slot reference in equal to.
|
||||
// they are not from the same relation.
|
||||
int exchangeTag = join.child(0).getOutput().stream().anyMatch(slot -> slot.getExprId().equals(
|
||||
((SlotReference) expr.child(1)).getExprId())) ? 1 : 0;
|
||||
return Pair.of(expr.child(exchangeTag), expr.child(1 ^ exchangeTag));
|
||||
|
||||
@ -174,7 +174,7 @@ public class Utils {
|
||||
public static List<Expression> getCorrelatedSlots(List<Expression> correlatedPredicates,
|
||||
List<Expression> correlatedSlots) {
|
||||
List<Expression> slots = new ArrayList<>();
|
||||
correlatedPredicates.stream().forEach(predicate -> {
|
||||
correlatedPredicates.forEach(predicate -> {
|
||||
if (!(predicate instanceof BinaryExpression)) {
|
||||
throw new AnalysisException("UnSupported expr type: " + correlatedPredicates);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user