You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2023/06/18 04:44:42 UTC
[doris] branch master updated: [fix](Nereids) cannot get output when partitioned table without any parititon (#20937)
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 c6d78c2d7b [fix](Nereids) cannot get output when partitioned table without any parititon (#20937)
c6d78c2d7b is described below
commit c6d78c2d7bd604d8f17b7849d56d18cf73e26201
Author: morrySnow <10...@users.noreply.github.com>
AuthorDate: Sun Jun 18 12:44:36 2023 +0800
[fix](Nereids) cannot get output when partitioned table without any parititon (#20937)
---
.../LogicalOlapScanToPhysicalOlapScan.java | 4 ++--
.../rewrite/mv/AbstractSelectMaterializedIndexRule.java | 2 +-
.../rewrite/mv/SelectMaterializedIndexWithAggregate.java | 16 ++++++++--------
.../nereids/trees/plans/logical/LogicalOlapScan.java | 7 ++++---
.../apache/doris/planner/MaterializedViewSelector.java | 2 +-
5 files changed, 16 insertions(+), 15 deletions(-)
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 ed1cbaf731..4619e05f15 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
@@ -58,7 +58,7 @@ public class LogicalOlapScanToPhysicalOlapScan extends OneImplementationRuleFact
olapScan.getSelectedPartitionIds(),
convertDistribution(olapScan),
olapScan.getPreAggStatus(),
- olapScan.getOutputByMvIndex(olapScan.getTable().getBaseIndexId()),
+ olapScan.getOutputByIndex(olapScan.getTable().getBaseIndexId()),
Optional.empty(),
olapScan.getLogicalProperties())
).toRule(RuleType.LOGICAL_OLAP_SCAN_TO_PHYSICAL_OLAP_SCAN_RULE);
@@ -83,7 +83,7 @@ public class LogicalOlapScanToPhysicalOlapScan extends OneImplementationRuleFact
if (olapScan.getSelectedIndexId() != olapScan.getTable().getBaseIndexId()) {
HashDistributionInfo hashDistributionInfo = (HashDistributionInfo) distributionInfo;
List<Slot> output = olapScan.getOutput();
- List<Slot> baseOutput = olapScan.getOutputByMvIndex(olapScan.getTable().getBaseIndexId());
+ List<Slot> baseOutput = olapScan.getOutputByIndex(olapScan.getTable().getBaseIndexId());
List<ExprId> hashColumns = Lists.newArrayList();
for (int i = 0; i < output.size(); i++) {
for (Column column : hashDistributionInfo.getDistributionColumns()) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/mv/AbstractSelectMaterializedIndexRule.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/mv/AbstractSelectMaterializedIndexRule.java
index c216b0b15c..46a57271d2 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/mv/AbstractSelectMaterializedIndexRule.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/mv/AbstractSelectMaterializedIndexRule.java
@@ -386,7 +386,7 @@ public abstract class AbstractSelectMaterializedIndexRule {
if (mvPlan.getSelectedIndexId() == mvPlan.getTable().getBaseIndexId()) {
return new SlotContext(baseSlotToMvSlot, mvNameToMvSlot);
}
- for (Slot mvSlot : mvPlan.getOutputByMvIndex(mvPlan.getSelectedIndexId())) {
+ for (Slot mvSlot : mvPlan.getOutputByIndex(mvPlan.getSelectedIndexId())) {
boolean isPushed = false;
for (Slot baseSlot : mvPlan.getOutput()) {
if (org.apache.doris.analysis.CreateMaterializedViewStmt.isMVColumnAggregate(mvSlot.getName())) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/mv/SelectMaterializedIndexWithAggregate.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/mv/SelectMaterializedIndexWithAggregate.java
index 0bcee51c1c..94348b7156 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/mv/SelectMaterializedIndexWithAggregate.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/mv/SelectMaterializedIndexWithAggregate.java
@@ -1172,7 +1172,7 @@ public class SelectMaterializedIndexWithAggregate extends AbstractSelectMaterial
Column mvColumn = context.checkContext.scan.getTable().getVisibleColumn(bitmapUnionColumn);
// has bitmap_union column
if (mvColumn != null && context.checkContext.valueNameToColumn.containsValue(mvColumn)) {
- Slot bitmapUnionSlot = context.checkContext.scan.getOutputByMvIndex(context.checkContext.index)
+ Slot bitmapUnionSlot = context.checkContext.scan.getOutputByIndex(context.checkContext.index)
.stream()
.filter(s -> bitmapUnionColumn.equalsIgnoreCase(normalizeName(s.getName())))
.findFirst()
@@ -1199,7 +1199,7 @@ public class SelectMaterializedIndexWithAggregate extends AbstractSelectMaterial
Column mvColumn = context.checkContext.scan.getTable().getVisibleColumn(countColumn);
// has bitmap_union_count column
if (mvColumn != null && context.checkContext.valueNameToColumn.containsValue(mvColumn)) {
- Slot countSlot = context.checkContext.scan.getOutputByMvIndex(context.checkContext.index)
+ Slot countSlot = context.checkContext.scan.getOutputByIndex(context.checkContext.index)
.stream()
.filter(s -> countColumn.equalsIgnoreCase(normalizeName(s.getName())))
.findFirst()
@@ -1235,7 +1235,7 @@ public class SelectMaterializedIndexWithAggregate extends AbstractSelectMaterial
if (mvColumn != null && context.checkContext.valueNameToColumn.containsValue(mvColumn)) {
Slot bitmapUnionCountSlot = context.checkContext.scan
- .getOutputByMvIndex(context.checkContext.index)
+ .getOutputByIndex(context.checkContext.index)
.stream()
.filter(s -> bitmapUnionCountColumn.equalsIgnoreCase(normalizeName(s.getName())))
.findFirst()
@@ -1262,7 +1262,7 @@ public class SelectMaterializedIndexWithAggregate extends AbstractSelectMaterial
if (mvColumn != null && context.checkContext.valueNameToColumn.containsValue(mvColumn)) {
Slot bitmapUnionCountSlot = context.checkContext.scan
- .getOutputByMvIndex(context.checkContext.index)
+ .getOutputByIndex(context.checkContext.index)
.stream()
.filter(s -> bitmapUnionCountColumn.equalsIgnoreCase(normalizeName(s.getName())))
.findFirst()
@@ -1297,7 +1297,7 @@ public class SelectMaterializedIndexWithAggregate extends AbstractSelectMaterial
Column mvColumn = context.checkContext.scan.getTable().getVisibleColumn(hllUnionColumn);
// has hll_union column
if (mvColumn != null && context.checkContext.valueNameToColumn.containsValue(mvColumn)) {
- Slot hllUnionSlot = context.checkContext.scan.getOutputByMvIndex(context.checkContext.index)
+ Slot hllUnionSlot = context.checkContext.scan.getOutputByIndex(context.checkContext.index)
.stream()
.filter(s -> hllUnionColumn.equalsIgnoreCase(normalizeName(s.getName())))
.findFirst()
@@ -1332,7 +1332,7 @@ public class SelectMaterializedIndexWithAggregate extends AbstractSelectMaterial
Column mvColumn = context.checkContext.scan.getTable().getVisibleColumn(hllUnionColumn);
// has hll_union column
if (mvColumn != null && context.checkContext.valueNameToColumn.containsValue(mvColumn)) {
- Slot hllUnionSlot = context.checkContext.scan.getOutputByMvIndex(context.checkContext.index)
+ Slot hllUnionSlot = context.checkContext.scan.getOutputByIndex(context.checkContext.index)
.stream()
.filter(s -> hllUnionColumn.equalsIgnoreCase(normalizeName(s.getName())))
.findFirst()
@@ -1367,7 +1367,7 @@ public class SelectMaterializedIndexWithAggregate extends AbstractSelectMaterial
Column mvColumn = context.checkContext.scan.getTable().getVisibleColumn(hllUnionColumn);
// has hll_union column
if (mvColumn != null && context.checkContext.valueNameToColumn.containsValue(mvColumn)) {
- Slot hllUnionSlot = context.checkContext.scan.getOutputByMvIndex(context.checkContext.index)
+ Slot hllUnionSlot = context.checkContext.scan.getOutputByIndex(context.checkContext.index)
.stream()
.filter(s -> hllUnionColumn.equalsIgnoreCase(normalizeName(s.getName())))
.findFirst()
@@ -1470,7 +1470,7 @@ public class SelectMaterializedIndexWithAggregate extends AbstractSelectMaterial
return outputs;
}
return ImmutableList.<NamedExpression>builder()
- .addAll(mvPlan.getOutputByMvIndex(mvPlan.getSelectedIndexId()))
+ .addAll(mvPlan.getOutputByIndex(mvPlan.getSelectedIndexId()))
.addAll(outputs.stream()
.filter(s -> !(s instanceof Slot))
.collect(ImmutableList.toImmutableList()))
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 e83ddd1cc7..84cdeab1ba 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
@@ -298,7 +298,7 @@ public class LogicalOlapScan extends LogicalRelation implements CatalogRelation,
@Override
public List<Slot> computeOutput() {
if (selectedIndexId != ((OlapTable) table).getBaseIndexId()) {
- return getOutputByMvIndex(selectedIndexId);
+ return getOutputByIndex(selectedIndexId);
}
List<Column> otherColumns = new ArrayList<>();
if (!Util.showHiddenColumns() && getTable().hasDeleteSign()
@@ -322,10 +322,11 @@ public class LogicalOlapScan extends LogicalRelation implements CatalogRelation,
* Get the slot under the index,
* and create a new slotReference for the slot that has not appeared in the materialized view.
*/
- public List<Slot> getOutputByMvIndex(long indexId) {
+ public List<Slot> getOutputByIndex(long indexId) {
OlapTable olapTable = (OlapTable) table;
// PhysicalStorageLayerAggregateTest has no visible index
- if (-1 == indexId) {
+ // when we have a partitioned table without any partition, visible index is empty
+ if (-1 == indexId || olapTable.getVisibleIndexIdToMeta().get(indexId) == null) {
return olapTable.getIndexMetaByIndexId(indexId).getSchema()
.stream().map(s -> generateUniqueSlot(s, indexId == ((OlapTable) table).getBaseIndexId()))
.collect(Collectors.toList());
diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/MaterializedViewSelector.java b/fe/fe-core/src/main/java/org/apache/doris/planner/MaterializedViewSelector.java
index 48153bab5d..a86b406d5c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/MaterializedViewSelector.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/MaterializedViewSelector.java
@@ -143,7 +143,7 @@ public class MaterializedViewSelector {
}
private Map<Long, List<Column>> predicates(OlapScanNode scanNode) throws AnalysisException {
- // Step1: all of predicates is compensating predicates
+ // Step1: all predicates is compensating predicates
Map<Long, MaterializedIndexMeta> candidateIndexIdToMeta = scanNode.getOlapTable().getVisibleIndexIdToMeta();
OlapTable table = scanNode.getOlapTable();
Preconditions.checkState(table != null);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org