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 818afa4c66 [fix](Nereids)fix some problem in CBO. (#12083)
818afa4c66 is described below
commit 818afa4c668767f9e2d1bfadc11a3b972f7c1745
Author: jakevin <[email protected]>
AuthorDate: Fri Aug 26 18:52:59 2022 +0800
[fix](Nereids)fix some problem in CBO. (#12083)
This PR fix three problem in Nereids.
- Add selected index, partition and tablet Info in LogicalOlapScan
- with JoinReorderContext in new LogicalJoin
- fix compute data size when no column size info in StatsCaculator
---
.../glue/translator/PhysicalPlanTranslator.java | 57 +++++++++++-----------
.../doris/nereids/rules/analysis/BindRelation.java | 5 +-
.../LogicalOlapScanToPhysicalOlapScan.java | 3 ++
.../doris/nereids/stats/StatsCalculator.java | 20 ++++----
.../nereids/trees/plans/logical/LogicalJoin.java | 18 +++++--
.../trees/plans/logical/LogicalOlapScan.java | 34 +++++++++++--
.../trees/plans/physical/PhysicalDistribution.java | 1 +
.../trees/plans/physical/PhysicalOlapScan.java | 27 +++++-----
.../apache/doris/statistics/StatsDeriveResult.java | 2 +-
.../doris/nereids/trees/plans/PlanEqualsTest.java | 9 +++-
10 files changed, 108 insertions(+), 68 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 c4902d2ab3..75e290d6bf 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
@@ -87,8 +87,8 @@ import java.util.stream.Collectors;
* Used to translate to physical plan generated by new optimizer to the plan
fragments.
*
* <STRONG>
- * ATTENTION:
- * Must always visit plan's children first when you implement a method to
translate from PhysicalPlan to PlanNode.
+ * ATTENTION:
+ * Must always visit plan's children first when you implement a method to
translate from PhysicalPlan to PlanNode.
* </STRONG>
*/
public class PhysicalPlanTranslator extends DefaultPlanVisitor<PlanFragment,
PlanTranslatorContext> {
@@ -264,7 +264,7 @@ public class PhysicalPlanTranslator extends
DefaultPlanVisitor<PlanFragment, Pla
return planFragment;
}
- /**
+ /*-
* Physical sort:
* 1. Build sortInfo
* There are two types of slotRef:
@@ -300,7 +300,7 @@ public class PhysicalPlanTranslator extends
DefaultPlanVisitor<PlanFragment, Pla
}
PlanFragment mergeFragment = createParentFragment(childFragment,
DataPartition.UNPARTITIONED, context);
ExchangeNode exchangeNode = (ExchangeNode) mergeFragment.getPlanRoot();
- //exchangeNode.limit/offset will be set in when translating
PhysicalLimit
+ // exchangeNode.limit/offset will be set in when translating
PhysicalLimit
exchangeNode.setMergeInfo(sortNode.getSortInfo());
return mergeFragment;
}
@@ -369,29 +369,29 @@ public class PhysicalPlanTranslator extends
DefaultPlanVisitor<PlanFragment, Pla
if (JoinUtils.shouldNestedLoopJoin(hashJoin)) {
throw new RuntimeException("Physical hash join could not execute
without equal join condition.");
- } else {
- List<Expr> execEqConjunctList =
hashJoin.getHashJoinConjuncts().stream()
- .map(EqualTo.class::cast)
- .map(e -> swapEqualToForChildrenOrder(e,
hashJoin.left().getOutput()))
- .map(e -> ExpressionTranslator.translate(e, context))
- .collect(Collectors.toList());
- TupleDescriptor outputDescriptor = context.generateTupleDesc();
- List<Expr> srcToOutput = hashJoin.getOutput().stream()
- .map(SlotReference.class::cast)
- .peek(s -> context.createSlotDesc(outputDescriptor, s))
- .map(e -> ExpressionTranslator.translate(e, context))
- .collect(Collectors.toList());
+ }
- HashJoinNode hashJoinNode = new
HashJoinNode(context.nextPlanNodeId(), leftFragmentPlanRoot,
- rightFragmentPlanRoot, JoinType.toJoinOperator(joinType),
execEqConjunctList, Lists.newArrayList(),
- srcToOutput, outputDescriptor, outputDescriptor);
+ List<Expr> execEqConjunctList =
hashJoin.getHashJoinConjuncts().stream()
+ .map(EqualTo.class::cast)
+ .map(e -> swapEqualToForChildrenOrder(e,
hashJoin.left().getOutput()))
+ .map(e -> ExpressionTranslator.translate(e, context))
+ .collect(Collectors.toList());
+ TupleDescriptor outputDescriptor = context.generateTupleDesc();
+ List<Expr> srcToOutput = hashJoin.getOutput().stream()
+ .map(SlotReference.class::cast)
+ .peek(s -> context.createSlotDesc(outputDescriptor, s))
+ .map(e -> ExpressionTranslator.translate(e, context))
+ .collect(Collectors.toList());
- hashJoinNode.setDistributionMode(DistributionMode.BROADCAST);
- hashJoinNode.setChild(0, leftFragmentPlanRoot);
- connectChildFragment(hashJoinNode, 1, leftFragment, rightFragment,
context);
- leftFragment.setPlanRoot(hashJoinNode);
- return leftFragment;
- }
+ HashJoinNode hashJoinNode = new HashJoinNode(context.nextPlanNodeId(),
leftFragmentPlanRoot,
+ rightFragmentPlanRoot, JoinType.toJoinOperator(joinType),
execEqConjunctList, Lists.newArrayList(),
+ srcToOutput, outputDescriptor, outputDescriptor);
+
+ hashJoinNode.setDistributionMode(DistributionMode.BROADCAST);
+ hashJoinNode.setChild(0, leftFragmentPlanRoot);
+ connectChildFragment(hashJoinNode, 1, leftFragment, rightFragment,
context);
+ leftFragment.setPlanRoot(hashJoinNode);
+ return leftFragment;
}
@Override
@@ -476,8 +476,8 @@ public class PhysicalPlanTranslator extends
DefaultPlanVisitor<PlanFragment, Pla
if (child instanceof ExchangeNode) {
ExchangeNode exchangeNode = (ExchangeNode) child;
exchangeNode.setLimit(physicalLimit.getLimit());
- //we do not check if this is a merging exchange here,
- //since this guaranteed by translating logic plan to physical plan
+ // we do not check if this is a merging exchange here,
+ // since this guaranteed by translating logic plan to physical plan
exchangeNode.setOffset(physicalLimit.getOffset());
if (exchangeNode.getChild(0) instanceof SortNode) {
SortNode sort = (SortNode) exchangeNode.getChild(0);
@@ -486,7 +486,7 @@ public class PhysicalPlanTranslator extends
DefaultPlanVisitor<PlanFragment, Pla
}
return inputFragment;
}
- //for other PlanNode, just set limit as limit+offset
+ // for other PlanNode, just set limit as limit+offset
child.setLimit(physicalLimit.getLimit() + physicalLimit.getOffset());
return inputFragment;
}
@@ -538,7 +538,6 @@ public class PhysicalPlanTranslator extends
DefaultPlanVisitor<PlanFragment, Pla
}
context.createSlotDesc(tupleDescriptor, (SlotReference) slot);
alreadyExists.add(slot.getExprId());
-
}
return tupleDescriptor;
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java
index 5a76471b60..e7fa08dc05 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java
@@ -19,6 +19,7 @@ package org.apache.doris.nereids.rules.analysis;
import org.apache.doris.catalog.Database;
import org.apache.doris.catalog.Env;
+import org.apache.doris.catalog.OlapTable;
import org.apache.doris.catalog.Table;
import org.apache.doris.catalog.TableIf.TableType;
import org.apache.doris.nereids.CascadesContext;
@@ -77,7 +78,7 @@ public class BindRelation extends OneAnalysisRuleFactory {
Table table = getTable(dbName, nameParts.get(0),
cascadesContext.getConnectContext().getEnv());
// TODO: should generate different Scan sub class according to table's
type
if (table.getType() == TableType.OLAP) {
- return new LogicalOlapScan(table, ImmutableList.of(dbName));
+ return new LogicalOlapScan((OlapTable) table,
ImmutableList.of(dbName));
} else if (table.getType() == TableType.VIEW) {
Plan viewPlan = parseAndAnalyzeView(table.getDdlSql(),
cascadesContext);
return new LogicalSubQueryAlias<>(table.getName(), viewPlan);
@@ -94,7 +95,7 @@ public class BindRelation extends OneAnalysisRuleFactory {
}
Table table = getTable(dbName, nameParts.get(1),
connectContext.getEnv());
if (table.getType() == TableType.OLAP) {
- return new LogicalOlapScan(table, ImmutableList.of(dbName));
+ return new LogicalOlapScan((OlapTable) table,
ImmutableList.of(dbName));
} else if (table.getType() == TableType.VIEW) {
Plan viewPlan = parseAndAnalyzeView(table.getDdlSql(),
cascadesContext);
return new LogicalSubQueryAlias<>(table.getName(), viewPlan);
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/LogicalOlapScanToPhysicalOlapScan.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/LogicalOlapScanToPhysicalOlapScan.java
index 304a37c623..1555450624 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/LogicalOlapScanToPhysicalOlapScan.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/LogicalOlapScanToPhysicalOlapScan.java
@@ -46,6 +46,9 @@ public class LogicalOlapScanToPhysicalOlapScan extends
OneImplementationRuleFact
new PhysicalOlapScan(
olapScan.getTable(),
olapScan.getQualifier(),
+ olapScan.getSelectedIndexId(),
+ olapScan.getSelectedTabletId(),
+ olapScan.getSelectedPartitionId(),
convertDistribution(olapScan),
Optional.empty(),
olapScan.getLogicalProperties())
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 62fb2d0e3c..6b03b68182 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
@@ -18,6 +18,7 @@
package org.apache.doris.nereids.stats;
import org.apache.doris.catalog.MaterializedIndex;
+import org.apache.doris.catalog.OlapTable;
import org.apache.doris.catalog.Partition;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.nereids.memo.GroupExpression;
@@ -59,7 +60,6 @@ import org.apache.doris.statistics.StatsDeriveResult;
import org.apache.doris.statistics.TableStats;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -225,10 +225,10 @@ public class StatsCalculator extends
DefaultPlanVisitor<StatsDeriveResult, Void>
// TODO: tmp mock the table stats, after we support the table stats, we
should remove this mock.
private TableStats mockRowCountInStatistic(Scan scan) throws
AnalysisException {
long cardinality = 0;
- if (scan instanceof PhysicalOlapScan) {
- PhysicalOlapScan olapScan = (PhysicalOlapScan) scan;
- for (long selectedPartitionId : olapScan.getSelectedPartitionId())
{
- final Partition partition =
olapScan.getTable().getPartition(selectedPartitionId);
+ if (scan instanceof PhysicalOlapScan || scan instanceof
LogicalOlapScan) {
+ OlapTable table = (OlapTable) scan.getTable();
+ for (long selectedPartitionId : table.getPartitionIds()) {
+ final Partition partition =
table.getPartition(selectedPartitionId);
final MaterializedIndex baseIndex = partition.getBaseIndex();
cardinality += baseIndex.getRowCount();
}
@@ -283,15 +283,13 @@ public class StatsCalculator extends
DefaultPlanVisitor<StatsDeriveResult, Void>
// TODO: Update data size and min/max value.
private StatsDeriveResult computeProject(Project project) {
List<NamedExpression> namedExpressionList = project.getProjects();
- Set<Slot> slotSet = new HashSet<>();
- for (NamedExpression namedExpression : namedExpressionList) {
- List<SlotReference> slotReferenceList =
namedExpression.collect(SlotReference.class::isInstance);
- slotSet.addAll(slotReferenceList);
- }
+ List<Slot> slotSet =
namedExpressionList.stream().flatMap(namedExpression -> {
+ List<Slot> slotReferenceList =
namedExpression.collect(SlotReference.class::isInstance);
+ return slotReferenceList.stream();
+ }).collect(Collectors.toList());
StatsDeriveResult stat = groupExpression.getCopyOfChildStats(0);
Map<Slot, ColumnStats> slotColumnStatsMap =
stat.getSlotToColumnStats();
slotColumnStatsMap.entrySet().removeIf(entry ->
!slotSet.contains(entry.getKey()));
return stat;
}
-
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalJoin.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalJoin.java
index 1c1efdc5e4..7f64840bbb 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalJoin.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalJoin.java
@@ -75,10 +75,17 @@ public class LogicalJoin<LEFT_CHILD_TYPE extends Plan,
RIGHT_CHILD_TYPE extends
this.joinReorderContext.copyFrom(joinReorderContext);
}
+ public LogicalJoin(JoinType joinType, List<Expression> hashJoinConjuncts,
Optional<Expression> condition,
+ Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties,
+ LEFT_CHILD_TYPE leftChild, RIGHT_CHILD_TYPE rightChild,
JoinReorderContext joinReorderContext) {
+ this(joinType, hashJoinConjuncts, condition, groupExpression,
logicalProperties, leftChild, rightChild);
+ this.joinReorderContext.copyFrom(joinReorderContext);
+ }
+
/**
* Constructor for LogicalJoinPlan.
*
- * @param joinType logical type for join
+ * @param joinType logical type for join
* @param condition on clause for join node
*/
public LogicalJoin(JoinType joinType, List<Expression> hashJoinConjuncts,
Optional<Expression> condition,
@@ -92,6 +99,7 @@ public class LogicalJoin<LEFT_CHILD_TYPE extends Plan,
RIGHT_CHILD_TYPE extends
/**
* get combination of hashJoinConjuncts and condition
+ *
* @return combine hashJoinConjuncts and condition by AND
*/
public Optional<Expression> getOtherJoinCondition() {
@@ -105,6 +113,7 @@ public class LogicalJoin<LEFT_CHILD_TYPE extends Plan,
RIGHT_CHILD_TYPE extends
/**
* hashJoinConjuncts and otherJoinCondition
+ *
* @return the combination of hashJoinConjuncts and otherJoinCondition
*/
public Optional<Expression> getOnClauseCondition() {
@@ -213,19 +222,20 @@ public class LogicalJoin<LEFT_CHILD_TYPE extends Plan,
RIGHT_CHILD_TYPE extends
@Override
public LogicalBinary<Plan, Plan> withChildren(List<Plan> children) {
Preconditions.checkArgument(children.size() == 2);
- return new LogicalJoin<>(joinType, hashJoinConjuncts,
otherJoinCondition, children.get(0), children.get(1));
+ return new LogicalJoin<>(joinType, hashJoinConjuncts,
otherJoinCondition, children.get(0), children.get(1),
+ joinReorderContext);
}
@Override
public Plan withGroupExpression(Optional<GroupExpression> groupExpression)
{
return new LogicalJoin<>(joinType, hashJoinConjuncts,
otherJoinCondition, groupExpression,
- Optional.of(logicalProperties), left(), right());
+ Optional.of(logicalProperties), left(), right(),
joinReorderContext);
}
@Override
public Plan withLogicalProperties(Optional<LogicalProperties>
logicalProperties) {
return new LogicalJoin<>(joinType, hashJoinConjuncts,
otherJoinCondition,
- Optional.empty(), logicalProperties, left(), right());
+ Optional.empty(), logicalProperties, left(), right(),
joinReorderContext);
}
@Override
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java
index a2d5372327..d17944b0bd 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java
@@ -18,6 +18,7 @@
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;
@@ -27,6 +28,7 @@ import
org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
import java.util.List;
import java.util.Objects;
@@ -36,13 +38,17 @@ import java.util.stream.Collectors;
/**
* Logical OlapScan.
*/
-public class LogicalOlapScan extends LogicalRelation {
+public class LogicalOlapScan extends LogicalRelation {
- public LogicalOlapScan(Table table) {
+ private final long selectedIndexId;
+ private final List<Long> selectedTabletId;
+ private final List<Long> selectedPartitionId;
+
+ public LogicalOlapScan(OlapTable table) {
this(table, ImmutableList.of());
}
- public LogicalOlapScan(Table table, List<String> qualifier) {
+ public LogicalOlapScan(OlapTable table, List<String> qualifier) {
this(table, qualifier, Optional.empty(), Optional.empty());
}
@@ -53,8 +59,26 @@ public class LogicalOlapScan extends LogicalRelation {
* @param qualifier table name qualifier
*/
public LogicalOlapScan(Table table, List<String> qualifier,
- Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties) {
+ Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties) {
super(PlanType.LOGICAL_OLAP_SCAN, table, qualifier, groupExpression,
logicalProperties);
+ this.selectedIndexId = getTable().getBaseIndexId();
+ this.selectedTabletId = Lists.newArrayList();
+ this.selectedPartitionId = getTable().getPartitionIds();
+ for (Partition partition : getTable().getAllPartitions()) {
+
selectedTabletId.addAll(partition.getBaseIndex().getTabletIdsInOrder());
+ }
+ }
+
+ public List<Long> getSelectedTabletId() {
+ return selectedTabletId;
+ }
+
+ public long getSelectedIndexId() {
+ return selectedIndexId;
+ }
+
+ public List<Long> getSelectedPartitionId() {
+ return selectedPartitionId;
}
@Override
@@ -68,7 +92,7 @@ public class LogicalOlapScan extends LogicalRelation {
return "ScanOlapTable ("
+ qualifiedName()
+ ", output: "
- +
getOutput().stream().map(Objects::toString).collect(Collectors.joining(", ",
"[", "]"))
+ +
getOutput().stream().map(Objects::toString).collect(Collectors.joining(", ",
"[", "]"))
+ ")";
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalDistribution.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalDistribution.java
index bec30a6393..7dd4651061 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalDistribution.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalDistribution.java
@@ -45,6 +45,7 @@ public class PhysicalDistribution<CHILD_TYPE extends Plan>
extends PhysicalUnary
public PhysicalDistribution(DistributionSpec spec,
Optional<GroupExpression> groupExpression,
LogicalProperties logicalProperties,
CHILD_TYPE child) {
super(PlanType.PHYSICAL_DISTRIBUTION, groupExpression,
logicalProperties, child);
+ this.distributionSpec = spec;
}
@Override
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalOlapScan.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalOlapScan.java
index 03ed6d9677..2146cf7aac 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalOlapScan.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalOlapScan.java
@@ -18,7 +18,6 @@
package org.apache.doris.nereids.trees.plans.physical;
import org.apache.doris.catalog.OlapTable;
-import org.apache.doris.catalog.Partition;
import org.apache.doris.nereids.memo.GroupExpression;
import org.apache.doris.nereids.properties.DistributionSpec;
import org.apache.doris.nereids.properties.LogicalProperties;
@@ -27,8 +26,6 @@ import org.apache.doris.nereids.trees.plans.PlanType;
import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
import org.apache.doris.nereids.util.Utils;
-import com.google.common.collect.Lists;
-
import java.util.List;
import java.util.Objects;
import java.util.Optional;
@@ -37,12 +34,11 @@ import java.util.Optional;
* Physical olap scan plan.
*/
public class PhysicalOlapScan extends PhysicalRelation {
+ private final OlapTable olapTable;
+ private final DistributionSpec distributionSpec;
private final long selectedIndexId;
private final List<Long> selectedTabletId;
private final List<Long> selectedPartitionId;
- private final OlapTable olapTable;
- private final DistributionSpec distributionSpec;
-
/**
* Constructor for PhysicalOlapScan.
@@ -50,17 +46,16 @@ public class PhysicalOlapScan extends PhysicalRelation {
* @param olapTable OlapTable in Doris
* @param qualifier qualifier of table name
*/
- public PhysicalOlapScan(OlapTable olapTable, List<String> qualifier,
DistributionSpec distributionSpec,
+ public PhysicalOlapScan(OlapTable olapTable, List<String> qualifier, long
selectedIndexId,
+ List<Long> selectedTabletId, List<Long> selectedPartitionId,
DistributionSpec distributionSpec,
Optional<GroupExpression> groupExpression, LogicalProperties
logicalProperties) {
super(PlanType.PHYSICAL_OLAP_SCAN, qualifier, groupExpression,
logicalProperties);
+
this.olapTable = olapTable;
- this.selectedIndexId = olapTable.getBaseIndexId();
- this.selectedTabletId = Lists.newArrayList();
- this.selectedPartitionId = olapTable.getPartitionIds();
+ this.selectedIndexId = selectedIndexId;
+ this.selectedTabletId = selectedTabletId;
+ this.selectedPartitionId = selectedPartitionId;
this.distributionSpec = distributionSpec;
- for (Partition partition : olapTable.getAllPartitions()) {
-
selectedTabletId.addAll(partition.getBaseIndex().getTabletIdsInOrder());
- }
}
public long getSelectedIndexId() {
@@ -117,11 +112,13 @@ public class PhysicalOlapScan extends PhysicalRelation {
@Override
public Plan withGroupExpression(Optional<GroupExpression> groupExpression)
{
- return new PhysicalOlapScan(olapTable, qualifier, distributionSpec,
groupExpression, logicalProperties);
+ return new PhysicalOlapScan(olapTable, qualifier, selectedIndexId,
selectedTabletId, selectedPartitionId,
+ distributionSpec, groupExpression, logicalProperties);
}
@Override
public Plan withLogicalProperties(Optional<LogicalProperties>
logicalProperties) {
- return new PhysicalOlapScan(olapTable, qualifier, distributionSpec,
Optional.empty(), logicalProperties.get());
+ return new PhysicalOlapScan(olapTable, qualifier, selectedIndexId,
selectedTabletId, selectedPartitionId,
+ distributionSpec, Optional.empty(), logicalProperties.get());
}
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/statistics/StatsDeriveResult.java
b/fe/fe-core/src/main/java/org/apache/doris/statistics/StatsDeriveResult.java
index 8406a67a20..95376c2832 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/statistics/StatsDeriveResult.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/statistics/StatsDeriveResult.java
@@ -83,7 +83,7 @@ public class StatsDeriveResult {
}
}
if (!exist) {
- return 1;
+ count = (float) 1.0;
}
return count * rowCount;
}
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 0d4f70176a..5f574d8342 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
@@ -18,6 +18,7 @@
package org.apache.doris.nereids.trees.plans;
import org.apache.doris.catalog.OlapTable;
+import org.apache.doris.catalog.Partition;
import org.apache.doris.nereids.properties.DistributionSpecHash;
import org.apache.doris.nereids.properties.LogicalProperties;
import org.apache.doris.nereids.properties.OrderKey;
@@ -47,6 +48,7 @@ import mockit.Mocked;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@@ -193,7 +195,12 @@ public class PlanEqualsTest {
@Mocked DistributionSpecHash distributionSpecHash) {
List<String> qualifier = Lists.newArrayList();
- PhysicalOlapScan olapScan = new PhysicalOlapScan(olapTable, qualifier,
distributionSpecHash, Optional.empty(),
+ ArrayList<Long> selectedTabletId = Lists.newArrayList();
+ for (Partition partition : olapTable.getAllPartitions()) {
+
selectedTabletId.addAll(partition.getBaseIndex().getTabletIdsInOrder());
+ }
+ PhysicalOlapScan olapScan = new PhysicalOlapScan(olapTable, qualifier,
olapTable.getBaseIndexId(),
+ selectedTabletId, olapTable.getPartitionIds(),
distributionSpecHash, Optional.empty(),
logicalProperties);
Assertions.assertEquals(olapScan, olapScan);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]