From 3e25973d0f6b3f261783254dcf865e474f31e4b3 Mon Sep 17 00:00:00 2001 From: morrySnow Date: Thu, 1 Sep 2022 20:05:53 +0800 Subject: [PATCH 1/8] [enhancement](Nereids)print slot qualified name in explain string --- .../src/main/java/org/apache/doris/analysis/SlotRef.java | 9 +++++++-- .../nereids/glue/translator/PlanTranslatorContext.java | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotRef.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotRef.java index 0bd5470ed0c183..9888d01cbfee44 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotRef.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotRef.java @@ -26,6 +26,7 @@ import org.apache.doris.common.AnalysisException; import org.apache.doris.common.io.Text; import org.apache.doris.common.util.ToSqlContext; +import org.apache.doris.qe.ConnectContext; import org.apache.doris.thrift.TExprNode; import org.apache.doris.thrift.TExprNodeType; import org.apache.doris.thrift.TSlotRef; @@ -205,9 +206,13 @@ public String toSqlImpl() { StringBuilder sb = new StringBuilder(); if (tblName != null) { - return tblName.toSql() + "." + label + sb.toString(); + return tblName.toSql() + "." + label; } else if (label != null) { - return label + sb.toString(); + if (ConnectContext.get().getSessionVariable().isEnableNereidsPlanner()) { + return label + "[#" + desc.getId().asInt() + "]"; + } else { + return label; + } } else if (desc.getSourceExprs() != null) { if (ToSqlContext.get() == null || ToSqlContext.get().isNeedSlotRefId()) { if (desc.getId().asInt() != 1) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PlanTranslatorContext.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PlanTranslatorContext.java index c412bedabea25b..b367c53fb222de 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PlanTranslatorContext.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PlanTranslatorContext.java @@ -121,7 +121,9 @@ public SlotDescriptor createSlotDesc(TupleDescriptor tupleDesc, SlotReference sl } slotDescriptor.setType(slotReference.getDataType().toCatalogDataType()); slotDescriptor.setIsMaterialized(true); - this.addExprIdSlotRefPair(slotReference.getExprId(), new SlotRef(slotDescriptor)); + SlotRef slotRef = new SlotRef(slotDescriptor); + slotRef.setLabel(slotReference.getQualifiedName()); + this.addExprIdSlotRefPair(slotReference.getExprId(), slotRef); slotDescriptor.setIsNullable(slotReference.nullable()); return slotDescriptor; } From ef3dca8bcc3a74e611a663b32f4b1659a54fdbff Mon Sep 17 00:00:00 2001 From: morrySnow Date: Thu, 1 Sep 2022 20:14:36 +0800 Subject: [PATCH 2/8] name --- .../doris/nereids/glue/translator/PlanTranslatorContext.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PlanTranslatorContext.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PlanTranslatorContext.java index b367c53fb222de..9634977653663a 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PlanTranslatorContext.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PlanTranslatorContext.java @@ -122,7 +122,7 @@ public SlotDescriptor createSlotDesc(TupleDescriptor tupleDesc, SlotReference sl slotDescriptor.setType(slotReference.getDataType().toCatalogDataType()); slotDescriptor.setIsMaterialized(true); SlotRef slotRef = new SlotRef(slotDescriptor); - slotRef.setLabel(slotReference.getQualifiedName()); + slotRef.setLabel(slotReference.getName()); this.addExprIdSlotRefPair(slotReference.getExprId(), slotRef); slotDescriptor.setIsNullable(slotReference.nullable()); return slotDescriptor; From 780b1d57cfb0ad3c576a2e8d06d4f1e5c2298950 Mon Sep 17 00:00:00 2001 From: morrySnow Date: Thu, 1 Sep 2022 20:24:50 +0800 Subject: [PATCH 3/8] fix ut --- .../src/main/java/org/apache/doris/analysis/SlotRef.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotRef.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotRef.java index 9888d01cbfee44..921670fbb2129d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotRef.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotRef.java @@ -208,7 +208,9 @@ public String toSqlImpl() { if (tblName != null) { return tblName.toSql() + "." + label; } else if (label != null) { - if (ConnectContext.get().getSessionVariable().isEnableNereidsPlanner()) { + if (ConnectContext.get() != null + && ConnectContext.get().getSessionVariable() != null + && ConnectContext.get().getSessionVariable().isEnableNereidsPlanner()) { return label + "[#" + desc.getId().asInt() + "]"; } else { return label; From c7fb938338ebd6ebd385a71a9cde57e5af974bcc Mon Sep 17 00:00:00 2001 From: morrySnow Date: Thu, 1 Sep 2022 21:17:35 +0800 Subject: [PATCH 4/8] do more --- .../translator/PhysicalPlanTranslator.java | 4 +- .../nereids/rules/analysis/BindRelation.java | 4 +- .../LogicalOlapScanToPhysicalOlapScan.java | 1 + .../trees/plans/logical/LogicalOlapScan.java | 22 +++++------ .../trees/plans/logical/LogicalRelation.java | 26 ++++++++----- .../plans/physical/PhysicalOlapScan.java | 39 +++++++++---------- .../plans/physical/PhysicalRelation.java | 7 +++- .../PhysicalPlanTranslatorTest.java | 11 +++--- .../nereids/jobs/RewriteTopDownJobTest.java | 4 +- .../jobs/cascades/DeriveStatsJobTest.java | 2 +- .../logical/AggregateDisassembleTest.java | 2 +- .../logical/FindHashConditionForJoinTest.java | 4 +- .../logical/NormalizeAggregateTest.java | 2 +- .../logical/PushDownPredicateTest.java | 6 +-- ...shDownPredicateThroughAggregationTest.java | 4 +- .../nereids/stats/StatsCalculatorTest.java | 4 +- .../nereids/trees/plans/PlanEqualsTest.java | 10 ++--- .../nereids/trees/plans/PlanOutputTest.java | 2 +- .../doris/nereids/util/PlanConstructor.java | 2 +- 19 files changed, 82 insertions(+), 74 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 9f2270eb35b638..50632182ae2fcc 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 @@ -217,13 +217,13 @@ public PlanFragment visitPhysicalOlapScan(PhysicalOlapScan olapScan, PlanTransla OlapTable olapTable = olapScan.getTable(); TupleDescriptor tupleDescriptor = generateTupleDesc(slotList, olapTable, context); tupleDescriptor.setTable(olapTable); - OlapScanNode olapScanNode = new OlapScanNode(context.nextPlanNodeId(), tupleDescriptor, olapTable.getName()); + OlapScanNode olapScanNode = new OlapScanNode(context.nextPlanNodeId(), tupleDescriptor, "OlapScanNode"); // TODO: Do we really need tableName here? TableName tableName = new TableName(null, "", ""); TableRef ref = new TableRef(tableName, null, null); BaseTableRef tableRef = new BaseTableRef(ref, olapTable, tableName); tupleDescriptor.setRef(tableRef); - olapScanNode.setSelectedPartitionIds(olapScan.getSelectedPartitionId()); + olapScanNode.setSelectedPartitionIds(olapScan.getSelectedPartitionIds()); try { olapScanNode.updateScanRangeInfoByNewMVSelector(olapScan.getSelectedIndexId(), false, ""); } catch (Exception e) { 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 5d05a0d13715e6..b0db722e4ec86a 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 @@ -78,7 +78,7 @@ private LogicalPlan bindWithCurrentDb(CascadesContext cascadesContext, List(table.getName(), viewPlan); @@ -95,7 +95,7 @@ private LogicalPlan bindWithDbNameFromNamePart(CascadesContext cascadesContext, } Table table = getTable(dbName, nameParts.get(1), connectContext.getEnv()); if (table.getType() == TableType.OLAP) { - return new LogicalOlapScan((OlapTable) table, ImmutableList.of(dbName)); + return new LogicalOlapScan((OlapTable) table, ImmutableList.of(dbName), table.getName()); } 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 ee48065739e19c..ff302cf80dd8cd 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,7 @@ public Rule build() { new PhysicalOlapScan( olapScan.getTable(), olapScan.getQualifier(), + olapScan.getName(), olapScan.getSelectedIndexId(), olapScan.getSelectedTabletId(), olapScan.getSelectedPartitionIds(), 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 fc4e5d082f22db..0e4a078eb11aaa 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 @@ -44,16 +44,16 @@ public class LogicalOlapScan extends LogicalRelation { private final boolean partitionPruned; public LogicalOlapScan(OlapTable table) { - this(table, ImmutableList.of()); + this(table, ImmutableList.of(), ""); } - public LogicalOlapScan(OlapTable table, List qualifier) { - this(table, qualifier, Optional.empty(), Optional.empty(), + public LogicalOlapScan(OlapTable table, List qualifier, String name) { + this(table, qualifier, name, Optional.empty(), Optional.empty(), table.getPartitionIds(), false); } - public LogicalOlapScan(Table table, List qualifier) { - this(table, qualifier, Optional.empty(), Optional.empty(), + public LogicalOlapScan(Table table, List qualifier, String name) { + this(table, qualifier, name, Optional.empty(), Optional.empty(), ((OlapTable) table).getPartitionIds(), false); } @@ -63,10 +63,10 @@ public LogicalOlapScan(Table table, List qualifier) { * @param table Doris table * @param qualifier table name qualifier */ - public LogicalOlapScan(Table table, List qualifier, Optional groupExpression, + public LogicalOlapScan(Table table, List qualifier, String name, Optional groupExpression, Optional logicalProperties, List selectedPartitionIdList, boolean partitionPruned) { - super(PlanType.LOGICAL_OLAP_SCAN, table, qualifier, + super(PlanType.LOGICAL_OLAP_SCAN, table, qualifier, name, groupExpression, logicalProperties, selectedPartitionIdList); this.selectedIndexId = getTable().getBaseIndexId(); this.selectedTabletId = Lists.newArrayList(); @@ -85,7 +85,7 @@ public OlapTable getTable() { @Override public String toString() { return Utils.toSqlString("LogicalOlapScan", - "qualifier", qualifiedName(), + "qualified", qualifiedName(), "output", getOutput() ); } @@ -103,18 +103,18 @@ public boolean equals(Object o) { @Override public Plan withGroupExpression(Optional groupExpression) { - return new LogicalOlapScan(table, qualifier, groupExpression, Optional.of(logicalProperties), + return new LogicalOlapScan(table, qualifier, name, groupExpression, Optional.of(logicalProperties), selectedPartitionIds, partitionPruned); } @Override public LogicalOlapScan withLogicalProperties(Optional logicalProperties) { - return new LogicalOlapScan(table, qualifier, Optional.empty(), logicalProperties, selectedPartitionIds, + return new LogicalOlapScan(table, qualifier, name, Optional.empty(), logicalProperties, selectedPartitionIds, partitionPruned); } public LogicalOlapScan withSelectedPartitionId(List selectedPartitionId) { - return new LogicalOlapScan(table, qualifier, Optional.empty(), Optional.of(logicalProperties), + return new LogicalOlapScan(table, qualifier, name, Optional.empty(), Optional.of(logicalProperties), selectedPartitionId, true); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalRelation.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalRelation.java index eee472ace79619..9063ab8bef9b0f 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalRelation.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalRelation.java @@ -29,7 +29,6 @@ import org.apache.doris.nereids.util.Utils; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; import java.util.Collections; import java.util.List; @@ -43,11 +42,11 @@ public abstract class LogicalRelation extends LogicalLeaf implements Scan { protected final Table table; protected final List qualifier; + protected final String name; + protected final List selectedPartitionIds; - protected List selectedPartitionIds = Lists.newArrayList(); - - public LogicalRelation(PlanType type, Table table, List qualifier) { - this(type, table, qualifier, Optional.empty(), Optional.empty(), Collections.emptyList()); + public LogicalRelation(PlanType type, Table table, List qualifier, String name) { + this(type, table, qualifier, name, Optional.empty(), Optional.empty(), Collections.emptyList()); } /** @@ -56,14 +55,17 @@ public LogicalRelation(PlanType type, Table table, List qualifier) { * @param table Doris table * @param qualifier qualified relation name */ - public LogicalRelation(PlanType type, Table table, List qualifier, + public LogicalRelation(PlanType type, Table table, List qualifier, String name, Optional groupExpression, Optional logicalProperties, - List selectedPartitionIdList) { + List selectedPartitionIds) { super(type, groupExpression, logicalProperties); this.table = Objects.requireNonNull(table, "table can not be null"); this.qualifier = ImmutableList.copyOf(Objects.requireNonNull(qualifier, "qualifier can not be null")); - this.selectedPartitionIds = selectedPartitionIdList; + this.name = Objects.requireNonNull(name); + this.selectedPartitionIds = ImmutableList.copyOf( + Objects.requireNonNull(selectedPartitionIds, "selectedPartitionIds can not be null")); + this.table.setName(Utils.qualifiedName(qualifier, name)); } public Table getTable() { @@ -74,6 +76,10 @@ public List getQualifier() { return qualifier; } + public String getName() { + return name; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -113,14 +119,14 @@ public List getExpressions() { * Full qualified name parts, i.e., concat qualifier and name into a list. */ public List qualified() { - return Utils.qualifiedNameParts(qualifier, table.getName()); + return Utils.qualifiedNameParts(qualifier, name); } /** * Full qualified table name, concat qualifier and name with `.` as separator. */ public String qualifiedName() { - return Utils.qualifiedName(qualifier, table.getName()); + return Utils.qualifiedName(qualifier, name); } public List getSelectedPartitionIds() { 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 5ae5adc3438008..64663bd0ab163c 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 @@ -37,8 +37,8 @@ public class PhysicalOlapScan extends PhysicalRelation { private final OlapTable olapTable; private final DistributionSpec distributionSpec; private final long selectedIndexId; - private final List selectedTabletId; - private final List selectedPartitionId; + private final List selectedTabletIds; + private final List selectedPartitionIds; /** * Constructor for PhysicalOlapScan. @@ -46,15 +46,14 @@ public class PhysicalOlapScan extends PhysicalRelation { * @param olapTable OlapTable in Doris * @param qualifier qualifier of table name */ - public PhysicalOlapScan(OlapTable olapTable, List qualifier, long selectedIndexId, - List selectedTabletId, List selectedPartitionId, DistributionSpec distributionSpec, + public PhysicalOlapScan(OlapTable olapTable, List qualifier, String name, long selectedIndexId, + List selectedTabletIds, List selectedPartitionIds, DistributionSpec distributionSpec, Optional groupExpression, LogicalProperties logicalProperties) { - super(PlanType.PHYSICAL_OLAP_SCAN, qualifier, groupExpression, logicalProperties); - + super(PlanType.PHYSICAL_OLAP_SCAN, qualifier, name, groupExpression, logicalProperties); this.olapTable = olapTable; this.selectedIndexId = selectedIndexId; - this.selectedTabletId = selectedTabletId; - this.selectedPartitionId = selectedPartitionId; + this.selectedTabletIds = selectedTabletIds; + this.selectedPartitionIds = selectedPartitionIds; this.distributionSpec = distributionSpec; } @@ -62,12 +61,12 @@ public long getSelectedIndexId() { return selectedIndexId; } - public List getSelectedTabletId() { - return selectedTabletId; + public List getSelectedTabletIds() { + return selectedTabletIds; } - public List getSelectedPartitionId() { - return selectedPartitionId; + public List getSelectedPartitionIds() { + return selectedPartitionIds; } public OlapTable getTable() { @@ -81,7 +80,7 @@ public DistributionSpec getDistributionSpec() { @Override public String toString() { return Utils.toSqlString("PhysicalOlapScan", - "qualifier", Utils.qualifiedName(qualifier, olapTable.getName()), + "qualified", Utils.qualifiedName(qualifier, name), "output", getOutput() ); } @@ -96,14 +95,14 @@ public boolean equals(Object o) { } PhysicalOlapScan that = (PhysicalOlapScan) o; return selectedIndexId == that.selectedIndexId - && Objects.equals(selectedTabletId, that.selectedTabletId) - && Objects.equals(selectedPartitionId, that.selectedPartitionId) + && Objects.equals(selectedTabletIds, that.selectedTabletIds) + && Objects.equals(selectedPartitionIds, that.selectedPartitionIds) && Objects.equals(olapTable, that.olapTable); } @Override public int hashCode() { - return Objects.hash(selectedIndexId, selectedPartitionId, selectedTabletId, olapTable); + return Objects.hash(selectedIndexId, selectedPartitionIds, selectedTabletIds, olapTable); } @Override @@ -113,13 +112,13 @@ public R accept(PlanVisitor visitor, C context) { @Override public Plan withGroupExpression(Optional groupExpression) { - return new PhysicalOlapScan(olapTable, qualifier, selectedIndexId, selectedTabletId, selectedPartitionId, - distributionSpec, groupExpression, logicalProperties); + return new PhysicalOlapScan(olapTable, qualifier, name, selectedIndexId, selectedTabletIds, + selectedPartitionIds, distributionSpec, groupExpression, logicalProperties); } @Override public Plan withLogicalProperties(Optional logicalProperties) { - return new PhysicalOlapScan(olapTable, qualifier, selectedIndexId, selectedTabletId, selectedPartitionId, - distributionSpec, Optional.empty(), logicalProperties.get()); + return new PhysicalOlapScan(olapTable, qualifier, name, selectedIndexId, selectedTabletIds, + selectedPartitionIds, distributionSpec, Optional.empty(), logicalProperties.get()); } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalRelation.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalRelation.java index 93898031c2d1e9..e2017385d3fe2c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalRelation.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalRelation.java @@ -37,16 +37,19 @@ public abstract class PhysicalRelation extends PhysicalLeaf implements Scan { protected final List qualifier; + protected final String name; + /** * Constructor for PhysicalScan. * * @param type node type * @param qualifier table's name */ - public PhysicalRelation(PlanType type, List qualifier, Optional groupExpression, - LogicalProperties logicalProperties) { + public PhysicalRelation(PlanType type, List qualifier, String name, + Optional groupExpression, LogicalProperties logicalProperties) { super(type, groupExpression, logicalProperties); this.qualifier = Objects.requireNonNull(qualifier, "qualifier can not be null"); + this.name = Objects.requireNonNull(name, "name can not be null"); } public List getQualifier() { diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslatorTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslatorTest.java index 8762ce125bfce3..2ba84882d3f140 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslatorTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslatorTest.java @@ -48,9 +48,8 @@ public class PhysicalPlanTranslatorTest { @Test public void testOlapPrune(@Mocked OlapTable t1, @Injectable LogicalProperties placeHolder) throws Exception { - List qualifierList = new ArrayList<>(); - qualifierList.add("test"); - qualifierList.add("t1"); + List qualifier = new ArrayList<>(); + qualifier.add("test"); List t1Output = new ArrayList<>(); SlotReference col1 = new SlotReference("col1", IntegerType.INSTANCE); SlotReference col2 = new SlotReference("col2", IntegerType.INSTANCE); @@ -59,17 +58,17 @@ public void testOlapPrune(@Mocked OlapTable t1, @Injectable LogicalProperties pl t1Output.add(col2); t1Output.add(col3); LogicalProperties t1Properties = new LogicalProperties(() -> t1Output); - PhysicalOlapScan scan = new PhysicalOlapScan(t1, qualifierList, 0L, + PhysicalOlapScan scan = new PhysicalOlapScan(t1, qualifier, "t1", 0L, Collections.emptyList(), Collections.emptyList(), null, Optional.empty(), t1Properties); Literal t1FilterRight = new IntegerLiteral(1); Expression t1FilterExpr = new GreaterThan(col1, t1FilterRight); PhysicalFilter filter = - new PhysicalFilter(t1FilterExpr, placeHolder, scan); + new PhysicalFilter<>(t1FilterExpr, placeHolder, scan); List projList = new ArrayList<>(); projList.add(col2); - PhysicalProject project = new PhysicalProject(projList, + PhysicalProject> project = new PhysicalProject<>(projList, placeHolder, filter); PlanTranslatorContext planTranslatorContext = new PlanTranslatorContext(); PhysicalPlanTranslator translator = new PhysicalPlanTranslator(); diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/RewriteTopDownJobTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/RewriteTopDownJobTest.java index 5d134de363d393..fe78250168823a 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/RewriteTopDownJobTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/RewriteTopDownJobTest.java @@ -104,12 +104,12 @@ public void testSimplestScene() { private static class LogicalBoundRelation extends LogicalRelation { public LogicalBoundRelation(Table table, List qualifier) { - super(PlanType.LOGICAL_BOUND_RELATION, table, qualifier); + super(PlanType.LOGICAL_BOUND_RELATION, table, qualifier, ""); } public LogicalBoundRelation(Table table, List qualifier, Optional groupExpression, Optional logicalProperties) { - super(PlanType.LOGICAL_BOUND_RELATION, table, qualifier, groupExpression, logicalProperties, + super(PlanType.LOGICAL_BOUND_RELATION, table, qualifier, "", groupExpression, logicalProperties, Collections.emptyList()); } diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/cascades/DeriveStatsJobTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/cascades/DeriveStatsJobTest.java index 3b5172ed2c12fe..42c5e5d6855bbd 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/cascades/DeriveStatsJobTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/cascades/DeriveStatsJobTest.java @@ -100,7 +100,7 @@ private LogicalOlapScan constructOlapSCan() { }}; OlapTable table1 = PlanConstructor.newOlapTable(tableId1, "t1", 0); - return new LogicalOlapScan(table1, Collections.emptyList()).withLogicalProperties( + return new LogicalOlapScan(table1, Collections.emptyList(), table1.getName()).withLogicalProperties( Optional.of(new LogicalProperties(() -> ImmutableList.of(slot1)))); } diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/AggregateDisassembleTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/AggregateDisassembleTest.java index 6d2dbc6d8a7be1..8543ed7246af8e 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/AggregateDisassembleTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/AggregateDisassembleTest.java @@ -49,7 +49,7 @@ public class AggregateDisassembleTest { @BeforeAll public final void beforeAll() { - rStudent = new LogicalOlapScan(PlanConstructor.student, ImmutableList.of("student")); + rStudent = new LogicalOlapScan(PlanConstructor.student, ImmutableList.of(""), "student"); } /** diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/FindHashConditionForJoinTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/FindHashConditionForJoinTest.java index 88fe1c71ab1010..00862b5b4e5b02 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/FindHashConditionForJoinTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/FindHashConditionForJoinTest.java @@ -57,8 +57,8 @@ class FindHashConditionForJoinTest { @Test public void testFindHashCondition() { - Plan student = new LogicalOlapScan(PlanConstructor.student, ImmutableList.of("student")); - Plan score = new LogicalOlapScan(PlanConstructor.score, ImmutableList.of("score")); + Plan student = new LogicalOlapScan(PlanConstructor.student, ImmutableList.of(""), "student"); + Plan score = new LogicalOlapScan(PlanConstructor.score, ImmutableList.of(""), "score"); Slot studentId = student.getOutput().get(0); Slot gender = student.getOutput().get(1); diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/NormalizeAggregateTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/NormalizeAggregateTest.java index fd44a0d628d80f..4a4611d5b45467 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/NormalizeAggregateTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/NormalizeAggregateTest.java @@ -48,7 +48,7 @@ public class NormalizeAggregateTest implements PatternMatchSupported { @BeforeAll public final void beforeAll() { - rStudent = new LogicalOlapScan(PlanConstructor.student, ImmutableList.of("student")); + rStudent = new LogicalOlapScan(PlanConstructor.student, ImmutableList.of(""), "student"); } /** diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/PushDownPredicateTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/PushDownPredicateTest.java index bbb3bbc826e1b3..bb0600adc040a8 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/PushDownPredicateTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/PushDownPredicateTest.java @@ -69,11 +69,11 @@ public class PushDownPredicateTest { */ @BeforeAll public final void beforeAll() { - rStudent = new LogicalOlapScan(PlanConstructor.student, ImmutableList.of("student")); + rStudent = new LogicalOlapScan(PlanConstructor.student, ImmutableList.of(""), "student"); - rScore = new LogicalOlapScan(PlanConstructor.score, ImmutableList.of("score")); + rScore = new LogicalOlapScan(PlanConstructor.score, ImmutableList.of(""), "score"); - rCourse = new LogicalOlapScan(PlanConstructor.course, ImmutableList.of("course")); + rCourse = new LogicalOlapScan(PlanConstructor.course, ImmutableList.of(""), "course"); } @Test diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/PushDownPredicateThroughAggregationTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/PushDownPredicateThroughAggregationTest.java index fe762357b05294..d9b7202f337730 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/PushDownPredicateThroughAggregationTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/PushDownPredicateThroughAggregationTest.java @@ -70,7 +70,7 @@ public class PushDownPredicateThroughAggregationTest { */ @Test public void pushDownPredicateOneFilterTest() { - Plan scan = new LogicalOlapScan(PlanConstructor.student, ImmutableList.of("student")); + Plan scan = new LogicalOlapScan(PlanConstructor.student, ImmutableList.of(""), "student"); Slot gender = scan.getOutput().get(1); Slot age = scan.getOutput().get(3); @@ -130,7 +130,7 @@ public void pushDownPredicateOneFilterTest() { */ @Test public void pushDownPredicateTwoFilterTest() { - Plan scan = new LogicalOlapScan(PlanConstructor.student, ImmutableList.of("student")); + Plan scan = new LogicalOlapScan(PlanConstructor.student, ImmutableList.of(""), "student"); Slot gender = scan.getOutput().get(1); Slot name = scan.getOutput().get(2); Slot age = scan.getOutput().get(3); diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/stats/StatsCalculatorTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/stats/StatsCalculatorTest.java index 848db9882b5f3d..edb25a3f4c1b6a 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/stats/StatsCalculatorTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/stats/StatsCalculatorTest.java @@ -225,8 +225,8 @@ public void testOlapScan() { }}; OlapTable table1 = PlanConstructor.newOlapTable(tableId1, "t1", 0); - LogicalOlapScan logicalOlapScan1 = new LogicalOlapScan(table1, Collections.emptyList()).withLogicalProperties( - Optional.of(new LogicalProperties(() -> ImmutableList.of(slot1)))); + LogicalOlapScan logicalOlapScan1 = new LogicalOlapScan(table1, Collections.emptyList(), table1.getName()) + .withLogicalProperties(Optional.of(new LogicalProperties(() -> ImmutableList.of(slot1)))); Group childGroup = new Group(); GroupExpression groupExpression = new GroupExpression(logicalOlapScan1, ImmutableList.of(childGroup)); Group ownerGroup = new Group(); 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 1fd9680a03dc4c..047e3411ab91a6 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 @@ -227,16 +227,16 @@ public void testPhysicalOlapScan( selectedTabletId.addAll(partition.getBaseIndex().getTabletIdsInOrder()); } - PhysicalOlapScan actual = new PhysicalOlapScan(olapTable, Lists.newArrayList("a"), olapTable.getBaseIndexId(), - selectedTabletId, olapTable.getPartitionIds(), distributionSpecHash, Optional.empty(), - logicalProperties); + PhysicalOlapScan actual = new PhysicalOlapScan(olapTable, Lists.newArrayList("a"), olapTable.getName(), + olapTable.getBaseIndexId(), selectedTabletId, olapTable.getPartitionIds(), distributionSpecHash, + Optional.empty(), logicalProperties); - PhysicalOlapScan expected = new PhysicalOlapScan(olapTable, Lists.newArrayList("a"), + PhysicalOlapScan expected = new PhysicalOlapScan(olapTable, Lists.newArrayList("a"), olapTable.getName(), olapTable.getBaseIndexId(), selectedTabletId, olapTable.getPartitionIds(), distributionSpecHash, Optional.empty(), logicalProperties); Assertions.assertEquals(expected, actual); - PhysicalOlapScan unexpected = new PhysicalOlapScan(olapTable, Lists.newArrayList("b"), + PhysicalOlapScan unexpected = new PhysicalOlapScan(olapTable, Lists.newArrayList("b"), olapTable.getName(), olapTable.getBaseIndexId(), selectedTabletId, olapTable.getPartitionIds(), distributionSpecHash, Optional.empty(), logicalProperties); Assertions.assertNotEquals(unexpected, actual); diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/PlanOutputTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/PlanOutputTest.java index 9bfff12def5052..c91afc9eb79955 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/PlanOutputTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/PlanOutputTest.java @@ -82,7 +82,7 @@ public void testWithOutput() { @Test public void testPhysicalPlanMustHaveLogicalProperties() { Assertions.assertThrows(NullPointerException.class, () -> - new PhysicalRelation(PlanType.PHYSICAL_OLAP_SCAN, ImmutableList.of("tbl"), Optional.empty(), null) { + new PhysicalRelation(PlanType.PHYSICAL_OLAP_SCAN, ImmutableList.of("db"), "tbl", Optional.empty(), null) { @Override public Plan withGroupExpression(Optional groupExpression) { return null; diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/util/PlanConstructor.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/util/PlanConstructor.java index 0d46c71d03e4a9..bb868acb1f12bf 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/util/PlanConstructor.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/util/PlanConstructor.java @@ -94,6 +94,6 @@ public static OlapTable newOlapTable(long tableId, String tableName, int hashCol // With OlapTable. // Warning: equals() of Table depends on tableId. public static LogicalOlapScan newLogicalOlapScan(long tableId, String tableName, int hashColumn) { - return new LogicalOlapScan(newOlapTable(tableId, tableName, hashColumn), ImmutableList.of("db")); + return new LogicalOlapScan(newOlapTable(tableId, tableName, hashColumn), ImmutableList.of("db"), tableName); } } From efad9cde3a4fa885f422fef38fdda0836cd012d0 Mon Sep 17 00:00:00 2001 From: morrySnow Date: Fri, 2 Sep 2022 13:42:57 +0800 Subject: [PATCH 5/8] fix ut failed --- .../org/apache/doris/catalog/Database.java | 2 ++ .../apache/doris/catalog/PartitionInfo.java | 1 + .../java/org/apache/doris/catalog/Table.java | 14 +++++++++++++ .../nereids/rules/analysis/BindRelation.java | 4 ++-- .../LogicalOlapScanToPhysicalOlapScan.java | 1 - .../trees/plans/logical/LogicalOlapScan.java | 20 +++++++++--------- .../trees/plans/logical/LogicalRelation.java | 20 ++++++------------ .../plans/physical/PhysicalOlapScan.java | 10 ++++----- .../plans/physical/PhysicalRelation.java | 5 +---- .../apache/doris/planner/OlapScanNode.java | 3 ++- .../PhysicalPlanTranslatorTest.java | 2 +- .../nereids/jobs/RewriteTopDownJobTest.java | 6 +++--- .../jobs/cascades/DeriveStatsJobTest.java | 2 +- .../logical/AggregateDisassembleTest.java | 2 +- .../logical/FindHashConditionForJoinTest.java | 4 ++-- .../logical/NormalizeAggregateTest.java | 2 +- .../logical/PushDownPredicateTest.java | 6 +++--- ...shDownPredicateThroughAggregationTest.java | 4 ++-- .../nereids/stats/StatsCalculatorTest.java | 2 +- .../nereids/trees/plans/PlanEqualsTest.java | 6 +++--- .../nereids/trees/plans/PlanOutputTest.java | 2 +- .../nereids/trees/plans/PlanToStringTest.java | 2 +- .../doris/nereids/util/PlanConstructor.java | 21 ++++++++++--------- 23 files changed, 74 insertions(+), 67 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java index b01a020f4a32e5..1017969955da01 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java @@ -361,6 +361,7 @@ public Pair createTableWithLock( public boolean createTable(Table table) { boolean result = true; + table.setQualifiedDbName(fullQualifiedName); String tableName = table.getName(); if (Env.isStoredTableNamesLowerCase()) { tableName = tableName.toLowerCase(); @@ -564,6 +565,7 @@ public void readFields(DataInput in) throws IOException { int numTables = in.readInt(); for (int i = 0; i < numTables; ++i) { Table table = Table.read(in); + table.setQualifiedDbName(fullQualifiedName); String tableName = table.getName(); nameToTable.put(tableName, table); idToTable.put(table.getId(), table); diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/PartitionInfo.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/PartitionInfo.java index c97fcccaa7c130..a18c5308c13394 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/PartitionInfo.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/PartitionInfo.java @@ -71,6 +71,7 @@ public class PartitionInfo implements Writable { protected Map idToTabletType; public PartitionInfo() { + this.type = PartitionType.UNPARTITIONED; this.idToDataProperty = new HashMap<>(); this.idToReplicaAllocation = new HashMap<>(); this.idToInMemory = new HashMap<>(); diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Table.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Table.java index 5602fa938923b9..3ff17902757f41 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Table.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Table.java @@ -33,6 +33,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.apache.commons.lang.NotImplementedException; +import org.apache.commons.lang.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -60,6 +61,7 @@ public abstract class Table extends MetaObject implements Writable, TableIf { protected long id; protected volatile String name; + protected volatile String qualifiedDbName; protected TableType type; protected long createTime; protected ReentrantReadWriteLock rwLock; @@ -248,6 +250,18 @@ public void setName(String newName) { name = newName; } + public void setQualifiedDbName(String qualifiedDbName) { + this.qualifiedDbName = qualifiedDbName; + } + + public String getQualifiedName() { + if (StringUtils.isEmpty(qualifiedDbName)) { + return name; + } else { + return qualifiedDbName + "." + name; + } + } + public TableType getType() { return type; } 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 b0db722e4ec86a..5d05a0d13715e6 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 @@ -78,7 +78,7 @@ private LogicalPlan bindWithCurrentDb(CascadesContext cascadesContext, List(table.getName(), viewPlan); @@ -95,7 +95,7 @@ private LogicalPlan bindWithDbNameFromNamePart(CascadesContext cascadesContext, } Table table = getTable(dbName, nameParts.get(1), connectContext.getEnv()); if (table.getType() == TableType.OLAP) { - return new LogicalOlapScan((OlapTable) table, ImmutableList.of(dbName), table.getName()); + 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 ff302cf80dd8cd..ee48065739e19c 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,7 +46,6 @@ public Rule build() { new PhysicalOlapScan( olapScan.getTable(), olapScan.getQualifier(), - olapScan.getName(), olapScan.getSelectedIndexId(), olapScan.getSelectedTabletId(), olapScan.getSelectedPartitionIds(), 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 0e4a078eb11aaa..5dfac9febba0b9 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 @@ -44,16 +44,16 @@ public class LogicalOlapScan extends LogicalRelation { private final boolean partitionPruned; public LogicalOlapScan(OlapTable table) { - this(table, ImmutableList.of(), ""); + this(table, ImmutableList.of()); } - public LogicalOlapScan(OlapTable table, List qualifier, String name) { - this(table, qualifier, name, Optional.empty(), Optional.empty(), + public LogicalOlapScan(OlapTable table, List qualifier) { + this(table, qualifier, Optional.empty(), Optional.empty(), table.getPartitionIds(), false); } - public LogicalOlapScan(Table table, List qualifier, String name) { - this(table, qualifier, name, Optional.empty(), Optional.empty(), + public LogicalOlapScan(Table table, List qualifier) { + this(table, qualifier, Optional.empty(), Optional.empty(), ((OlapTable) table).getPartitionIds(), false); } @@ -63,10 +63,10 @@ public LogicalOlapScan(Table table, List qualifier, String name) { * @param table Doris table * @param qualifier table name qualifier */ - public LogicalOlapScan(Table table, List qualifier, String name, Optional groupExpression, + public LogicalOlapScan(Table table, List qualifier, Optional groupExpression, Optional logicalProperties, List selectedPartitionIdList, boolean partitionPruned) { - super(PlanType.LOGICAL_OLAP_SCAN, table, qualifier, name, + super(PlanType.LOGICAL_OLAP_SCAN, table, qualifier, groupExpression, logicalProperties, selectedPartitionIdList); this.selectedIndexId = getTable().getBaseIndexId(); this.selectedTabletId = Lists.newArrayList(); @@ -103,18 +103,18 @@ public boolean equals(Object o) { @Override public Plan withGroupExpression(Optional groupExpression) { - return new LogicalOlapScan(table, qualifier, name, groupExpression, Optional.of(logicalProperties), + return new LogicalOlapScan(table, qualifier, groupExpression, Optional.of(logicalProperties), selectedPartitionIds, partitionPruned); } @Override public LogicalOlapScan withLogicalProperties(Optional logicalProperties) { - return new LogicalOlapScan(table, qualifier, name, Optional.empty(), logicalProperties, selectedPartitionIds, + return new LogicalOlapScan(table, qualifier, Optional.empty(), logicalProperties, selectedPartitionIds, partitionPruned); } public LogicalOlapScan withSelectedPartitionId(List selectedPartitionId) { - return new LogicalOlapScan(table, qualifier, name, Optional.empty(), Optional.of(logicalProperties), + return new LogicalOlapScan(table, qualifier, Optional.empty(), Optional.of(logicalProperties), selectedPartitionId, true); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalRelation.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalRelation.java index 9063ab8bef9b0f..bab2f62ca86d9a 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalRelation.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalRelation.java @@ -42,11 +42,10 @@ public abstract class LogicalRelation extends LogicalLeaf implements Scan { protected final Table table; protected final List qualifier; - protected final String name; protected final List selectedPartitionIds; - public LogicalRelation(PlanType type, Table table, List qualifier, String name) { - this(type, table, qualifier, name, Optional.empty(), Optional.empty(), Collections.emptyList()); + public LogicalRelation(PlanType type, Table table, List qualifier) { + this(type, table, qualifier, Optional.empty(), Optional.empty(), Collections.emptyList()); } /** @@ -55,17 +54,14 @@ public LogicalRelation(PlanType type, Table table, List qualifier, Strin * @param table Doris table * @param qualifier qualified relation name */ - public LogicalRelation(PlanType type, Table table, List qualifier, String name, - Optional groupExpression, - Optional logicalProperties, + public LogicalRelation(PlanType type, Table table, List qualifier, + Optional groupExpression, Optional logicalProperties, List selectedPartitionIds) { super(type, groupExpression, logicalProperties); this.table = Objects.requireNonNull(table, "table can not be null"); this.qualifier = ImmutableList.copyOf(Objects.requireNonNull(qualifier, "qualifier can not be null")); - this.name = Objects.requireNonNull(name); this.selectedPartitionIds = ImmutableList.copyOf( Objects.requireNonNull(selectedPartitionIds, "selectedPartitionIds can not be null")); - this.table.setName(Utils.qualifiedName(qualifier, name)); } public Table getTable() { @@ -76,10 +72,6 @@ public List getQualifier() { return qualifier; } - public String getName() { - return name; - } - @Override public boolean equals(Object o) { if (this == o) { @@ -119,14 +111,14 @@ public List getExpressions() { * Full qualified name parts, i.e., concat qualifier and name into a list. */ public List qualified() { - return Utils.qualifiedNameParts(qualifier, name); + return Utils.qualifiedNameParts(qualifier, table.getName()); } /** * Full qualified table name, concat qualifier and name with `.` as separator. */ public String qualifiedName() { - return Utils.qualifiedName(qualifier, name); + return Utils.qualifiedName(qualifier, table.getName()); } public List getSelectedPartitionIds() { 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 64663bd0ab163c..61ee6a5e094f01 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 @@ -46,10 +46,10 @@ public class PhysicalOlapScan extends PhysicalRelation { * @param olapTable OlapTable in Doris * @param qualifier qualifier of table name */ - public PhysicalOlapScan(OlapTable olapTable, List qualifier, String name, long selectedIndexId, + public PhysicalOlapScan(OlapTable olapTable, List qualifier, long selectedIndexId, List selectedTabletIds, List selectedPartitionIds, DistributionSpec distributionSpec, Optional groupExpression, LogicalProperties logicalProperties) { - super(PlanType.PHYSICAL_OLAP_SCAN, qualifier, name, groupExpression, logicalProperties); + super(PlanType.PHYSICAL_OLAP_SCAN, qualifier, groupExpression, logicalProperties); this.olapTable = olapTable; this.selectedIndexId = selectedIndexId; this.selectedTabletIds = selectedTabletIds; @@ -80,7 +80,7 @@ public DistributionSpec getDistributionSpec() { @Override public String toString() { return Utils.toSqlString("PhysicalOlapScan", - "qualified", Utils.qualifiedName(qualifier, name), + "qualified", Utils.qualifiedName(qualifier, olapTable.getName()), "output", getOutput() ); } @@ -112,13 +112,13 @@ public R accept(PlanVisitor visitor, C context) { @Override public Plan withGroupExpression(Optional groupExpression) { - return new PhysicalOlapScan(olapTable, qualifier, name, selectedIndexId, selectedTabletIds, + return new PhysicalOlapScan(olapTable, qualifier, selectedIndexId, selectedTabletIds, selectedPartitionIds, distributionSpec, groupExpression, logicalProperties); } @Override public Plan withLogicalProperties(Optional logicalProperties) { - return new PhysicalOlapScan(olapTable, qualifier, name, selectedIndexId, selectedTabletIds, + return new PhysicalOlapScan(olapTable, qualifier, selectedIndexId, selectedTabletIds, selectedPartitionIds, distributionSpec, Optional.empty(), logicalProperties.get()); } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalRelation.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalRelation.java index e2017385d3fe2c..330801cd2465c6 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalRelation.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalRelation.java @@ -37,19 +37,16 @@ public abstract class PhysicalRelation extends PhysicalLeaf implements Scan { protected final List qualifier; - protected final String name; - /** * Constructor for PhysicalScan. * * @param type node type * @param qualifier table's name */ - public PhysicalRelation(PlanType type, List qualifier, String name, + public PhysicalRelation(PlanType type, List qualifier, Optional groupExpression, LogicalProperties logicalProperties) { super(type, groupExpression, logicalProperties); this.qualifier = Objects.requireNonNull(qualifier, "qualifier can not be null"); - this.name = Objects.requireNonNull(name, "name can not be null"); } public List getQualifier() { diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java b/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java index 3c82be05f6a427..2ee08fb24a53c1 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java +++ b/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java @@ -816,7 +816,8 @@ public String getNodeExplainString(String prefix, TExplainLevel detailLevel) { StringBuilder output = new StringBuilder(); String indexName = olapTable.getIndexNameById(selectedIndexId); - output.append(prefix).append("TABLE: ").append(olapTable.getName()).append("(").append(indexName).append(")"); + output.append(prefix).append("TABLE: ").append(olapTable.getQualifiedName()) + .append("(").append(indexName).append(")"); if (detailLevel == TExplainLevel.BRIEF) { return output.toString(); } diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslatorTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslatorTest.java index 2ba84882d3f140..6968d4d793e2f8 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslatorTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslatorTest.java @@ -58,7 +58,7 @@ public void testOlapPrune(@Mocked OlapTable t1, @Injectable LogicalProperties pl t1Output.add(col2); t1Output.add(col3); LogicalProperties t1Properties = new LogicalProperties(() -> t1Output); - PhysicalOlapScan scan = new PhysicalOlapScan(t1, qualifier, "t1", 0L, + PhysicalOlapScan scan = new PhysicalOlapScan(t1, qualifier, 0L, Collections.emptyList(), Collections.emptyList(), null, Optional.empty(), t1Properties); diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/RewriteTopDownJobTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/RewriteTopDownJobTest.java index fe78250168823a..ad6f445a1b89ff 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/RewriteTopDownJobTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/RewriteTopDownJobTest.java @@ -104,13 +104,13 @@ public void testSimplestScene() { private static class LogicalBoundRelation extends LogicalRelation { public LogicalBoundRelation(Table table, List qualifier) { - super(PlanType.LOGICAL_BOUND_RELATION, table, qualifier, ""); + super(PlanType.LOGICAL_BOUND_RELATION, table, qualifier); } public LogicalBoundRelation(Table table, List qualifier, Optional groupExpression, Optional logicalProperties) { - super(PlanType.LOGICAL_BOUND_RELATION, table, qualifier, "", groupExpression, logicalProperties, - Collections.emptyList()); + super(PlanType.LOGICAL_BOUND_RELATION, table, qualifier, + groupExpression, logicalProperties, Collections.emptyList()); } @Override diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/cascades/DeriveStatsJobTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/cascades/DeriveStatsJobTest.java index 42c5e5d6855bbd..3b5172ed2c12fe 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/cascades/DeriveStatsJobTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/cascades/DeriveStatsJobTest.java @@ -100,7 +100,7 @@ private LogicalOlapScan constructOlapSCan() { }}; OlapTable table1 = PlanConstructor.newOlapTable(tableId1, "t1", 0); - return new LogicalOlapScan(table1, Collections.emptyList(), table1.getName()).withLogicalProperties( + return new LogicalOlapScan(table1, Collections.emptyList()).withLogicalProperties( Optional.of(new LogicalProperties(() -> ImmutableList.of(slot1)))); } diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/AggregateDisassembleTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/AggregateDisassembleTest.java index 8543ed7246af8e..d04eb4feb922c3 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/AggregateDisassembleTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/AggregateDisassembleTest.java @@ -49,7 +49,7 @@ public class AggregateDisassembleTest { @BeforeAll public final void beforeAll() { - rStudent = new LogicalOlapScan(PlanConstructor.student, ImmutableList.of(""), "student"); + rStudent = new LogicalOlapScan(PlanConstructor.student, ImmutableList.of("")); } /** diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/FindHashConditionForJoinTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/FindHashConditionForJoinTest.java index 00862b5b4e5b02..5bd5a3d35156a5 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/FindHashConditionForJoinTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/FindHashConditionForJoinTest.java @@ -57,8 +57,8 @@ class FindHashConditionForJoinTest { @Test public void testFindHashCondition() { - Plan student = new LogicalOlapScan(PlanConstructor.student, ImmutableList.of(""), "student"); - Plan score = new LogicalOlapScan(PlanConstructor.score, ImmutableList.of(""), "score"); + Plan student = new LogicalOlapScan(PlanConstructor.student, ImmutableList.of("")); + Plan score = new LogicalOlapScan(PlanConstructor.score, ImmutableList.of("")); Slot studentId = student.getOutput().get(0); Slot gender = student.getOutput().get(1); diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/NormalizeAggregateTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/NormalizeAggregateTest.java index 4a4611d5b45467..080151b246f950 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/NormalizeAggregateTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/NormalizeAggregateTest.java @@ -48,7 +48,7 @@ public class NormalizeAggregateTest implements PatternMatchSupported { @BeforeAll public final void beforeAll() { - rStudent = new LogicalOlapScan(PlanConstructor.student, ImmutableList.of(""), "student"); + rStudent = new LogicalOlapScan(PlanConstructor.student, ImmutableList.of("")); } /** diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/PushDownPredicateTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/PushDownPredicateTest.java index bb0600adc040a8..1f8e0b546acab2 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/PushDownPredicateTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/PushDownPredicateTest.java @@ -69,11 +69,11 @@ public class PushDownPredicateTest { */ @BeforeAll public final void beforeAll() { - rStudent = new LogicalOlapScan(PlanConstructor.student, ImmutableList.of(""), "student"); + rStudent = new LogicalOlapScan(PlanConstructor.student, ImmutableList.of("")); - rScore = new LogicalOlapScan(PlanConstructor.score, ImmutableList.of(""), "score"); + rScore = new LogicalOlapScan(PlanConstructor.score, ImmutableList.of("")); - rCourse = new LogicalOlapScan(PlanConstructor.course, ImmutableList.of(""), "course"); + rCourse = new LogicalOlapScan(PlanConstructor.course, ImmutableList.of("")); } @Test diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/PushDownPredicateThroughAggregationTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/PushDownPredicateThroughAggregationTest.java index d9b7202f337730..029caf6c4c1f5d 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/PushDownPredicateThroughAggregationTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/PushDownPredicateThroughAggregationTest.java @@ -70,7 +70,7 @@ public class PushDownPredicateThroughAggregationTest { */ @Test public void pushDownPredicateOneFilterTest() { - Plan scan = new LogicalOlapScan(PlanConstructor.student, ImmutableList.of(""), "student"); + Plan scan = new LogicalOlapScan(PlanConstructor.student, ImmutableList.of("")); Slot gender = scan.getOutput().get(1); Slot age = scan.getOutput().get(3); @@ -130,7 +130,7 @@ public void pushDownPredicateOneFilterTest() { */ @Test public void pushDownPredicateTwoFilterTest() { - Plan scan = new LogicalOlapScan(PlanConstructor.student, ImmutableList.of(""), "student"); + Plan scan = new LogicalOlapScan(PlanConstructor.student, ImmutableList.of("")); Slot gender = scan.getOutput().get(1); Slot name = scan.getOutput().get(2); Slot age = scan.getOutput().get(3); diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/stats/StatsCalculatorTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/stats/StatsCalculatorTest.java index edb25a3f4c1b6a..0f47477f4cc93e 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/stats/StatsCalculatorTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/stats/StatsCalculatorTest.java @@ -225,7 +225,7 @@ public void testOlapScan() { }}; OlapTable table1 = PlanConstructor.newOlapTable(tableId1, "t1", 0); - LogicalOlapScan logicalOlapScan1 = new LogicalOlapScan(table1, Collections.emptyList(), table1.getName()) + LogicalOlapScan logicalOlapScan1 = new LogicalOlapScan(table1, Collections.emptyList()) .withLogicalProperties(Optional.of(new LogicalProperties(() -> ImmutableList.of(slot1)))); Group childGroup = new Group(); GroupExpression groupExpression = new GroupExpression(logicalOlapScan1, ImmutableList.of(childGroup)); 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 047e3411ab91a6..5f72875361942b 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 @@ -227,16 +227,16 @@ public void testPhysicalOlapScan( selectedTabletId.addAll(partition.getBaseIndex().getTabletIdsInOrder()); } - PhysicalOlapScan actual = new PhysicalOlapScan(olapTable, Lists.newArrayList("a"), olapTable.getName(), + PhysicalOlapScan actual = new PhysicalOlapScan(olapTable, Lists.newArrayList("a"), olapTable.getBaseIndexId(), selectedTabletId, olapTable.getPartitionIds(), distributionSpecHash, Optional.empty(), logicalProperties); - PhysicalOlapScan expected = new PhysicalOlapScan(olapTable, Lists.newArrayList("a"), olapTable.getName(), + PhysicalOlapScan expected = new PhysicalOlapScan(olapTable, Lists.newArrayList("a"), olapTable.getBaseIndexId(), selectedTabletId, olapTable.getPartitionIds(), distributionSpecHash, Optional.empty(), logicalProperties); Assertions.assertEquals(expected, actual); - PhysicalOlapScan unexpected = new PhysicalOlapScan(olapTable, Lists.newArrayList("b"), olapTable.getName(), + PhysicalOlapScan unexpected = new PhysicalOlapScan(olapTable, Lists.newArrayList("b"), olapTable.getBaseIndexId(), selectedTabletId, olapTable.getPartitionIds(), distributionSpecHash, Optional.empty(), logicalProperties); Assertions.assertNotEquals(unexpected, actual); diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/PlanOutputTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/PlanOutputTest.java index c91afc9eb79955..8cc59e7c5d405a 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/PlanOutputTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/PlanOutputTest.java @@ -82,7 +82,7 @@ public void testWithOutput() { @Test public void testPhysicalPlanMustHaveLogicalProperties() { Assertions.assertThrows(NullPointerException.class, () -> - new PhysicalRelation(PlanType.PHYSICAL_OLAP_SCAN, ImmutableList.of("db"), "tbl", Optional.empty(), null) { + new PhysicalRelation(PlanType.PHYSICAL_OLAP_SCAN, ImmutableList.of("db"), Optional.empty(), null) { @Override public Plan withGroupExpression(Optional groupExpression) { return null; diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/PlanToStringTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/PlanToStringTest.java index 63822eeaaf0ad2..5493ca9c6acf49 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/PlanToStringTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/PlanToStringTest.java @@ -82,7 +82,7 @@ public void testLogicalJoin(@Mocked Plan left, @Mocked Plan right) { public void testLogicalOlapScan() { LogicalOlapScan plan = PlanConstructor.newLogicalOlapScan(0, "table", 0); Assertions.assertTrue( - plan.toString().matches("LogicalOlapScan \\( qualifier=db\\.table, output=\\[id#\\d+, name#\\d+] \\)")); + plan.toString().matches("LogicalOlapScan \\( qualified=db\\.table, output=\\[id#\\d+, name#\\d+] \\)")); } @Test diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/util/PlanConstructor.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/util/PlanConstructor.java index bb868acb1f12bf..4bad76c26e829a 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/util/PlanConstructor.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/util/PlanConstructor.java @@ -22,6 +22,7 @@ import org.apache.doris.catalog.HashDistributionInfo; import org.apache.doris.catalog.KeysType; import org.apache.doris.catalog.OlapTable; +import org.apache.doris.catalog.PartitionInfo; import org.apache.doris.catalog.Type; import org.apache.doris.nereids.trees.plans.logical.LogicalOlapScan; import org.apache.doris.thrift.TStorageType; @@ -41,31 +42,31 @@ public class PlanConstructor { new Column("gender", Type.INT, false, AggregateType.NONE, "0", ""), new Column("name", Type.STRING, true, AggregateType.NONE, "", ""), new Column("age", Type.INT, true, AggregateType.NONE, "", "")), - KeysType.PRIMARY_KEYS, null, null); - score = new OlapTable(1L, "course", + KeysType.PRIMARY_KEYS, new PartitionInfo(), null); + score = new OlapTable(1L, "score", ImmutableList.of(new Column("sid", Type.INT, true, AggregateType.NONE, "0", ""), new Column("cid", Type.INT, true, AggregateType.NONE, "", ""), new Column("grade", Type.DOUBLE, true, AggregateType.NONE, "", "")), - KeysType.PRIMARY_KEYS, null, null); + KeysType.PRIMARY_KEYS, new PartitionInfo(), null); course = new OlapTable(2L, "course", ImmutableList.of(new Column("cid", Type.INT, true, AggregateType.NONE, "0", ""), new Column("name", Type.STRING, true, AggregateType.NONE, "", ""), new Column("teacher", Type.STRING, true, AggregateType.NONE, "", "")), - KeysType.PRIMARY_KEYS, null, null); + KeysType.PRIMARY_KEYS, new PartitionInfo(), null); student.setIndexMeta(-1, - "base", + "student", student.getFullSchema(), 0, 0, (short) 0, TStorageType.COLUMN, KeysType.PRIMARY_KEYS); score.setIndexMeta(-1, - "base", + "score", score.getFullSchema(), 0, 0, (short) 0, TStorageType.COLUMN, KeysType.PRIMARY_KEYS); course.setIndexMeta(-1, - "base", + "course", course.getFullSchema(), 0, 0, (short) 0, TStorageType.COLUMN, @@ -81,9 +82,9 @@ public static OlapTable newOlapTable(long tableId, String tableName, int hashCol ImmutableList.of(columns.get(hashColumn))); OlapTable table = new OlapTable(tableId, tableName, columns, - KeysType.PRIMARY_KEYS, null, hashDistributionInfo); + KeysType.PRIMARY_KEYS, new PartitionInfo(), hashDistributionInfo); table.setIndexMeta(-1, - "base", + tableName, table.getFullSchema(), 0, 0, (short) 0, TStorageType.COLUMN, @@ -94,6 +95,6 @@ public static OlapTable newOlapTable(long tableId, String tableName, int hashCol // With OlapTable. // Warning: equals() of Table depends on tableId. public static LogicalOlapScan newLogicalOlapScan(long tableId, String tableName, int hashColumn) { - return new LogicalOlapScan(newOlapTable(tableId, tableName, hashColumn), ImmutableList.of("db"), tableName); + return new LogicalOlapScan(newOlapTable(tableId, tableName, hashColumn), ImmutableList.of("db")); } } From d0fd4c1f78f0ef6bb92d7b97ce0c57ac74f432b9 Mon Sep 17 00:00:00 2001 From: morrySnow Date: Fri, 2 Sep 2022 14:32:40 +0800 Subject: [PATCH 6/8] fix bug --- .../nereids/glue/translator/PhysicalPlanTranslatorTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslatorTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslatorTest.java index 6968d4d793e2f8..29378e61c11dfb 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslatorTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslatorTest.java @@ -58,7 +58,7 @@ public void testOlapPrune(@Mocked OlapTable t1, @Injectable LogicalProperties pl t1Output.add(col2); t1Output.add(col3); LogicalProperties t1Properties = new LogicalProperties(() -> t1Output); - PhysicalOlapScan scan = new PhysicalOlapScan(t1, qualifier, 0L, + PhysicalOlapScan scan = new PhysicalOlapScan(t1, qualifier, 0L, Collections.emptyList(), Collections.emptyList(), null, Optional.empty(), t1Properties); From a6fbb2f220d0978467c9a6731b3f6a1a41695205 Mon Sep 17 00:00:00 2001 From: morrySnow <101034200+morrysnow@users.noreply.github.com> Date: Fri, 2 Sep 2022 17:04:25 +0800 Subject: [PATCH 7/8] fix comment --- fe/fe-core/src/main/java/org/apache/doris/catalog/Table.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Table.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Table.java index 3ff17902757f41..e46080e4c97a6d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Table.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Table.java @@ -250,7 +250,7 @@ public void setName(String newName) { name = newName; } - public void setQualifiedDbName(String qualifiedDbName) { + void setQualifiedDbName(String qualifiedDbName) { this.qualifiedDbName = qualifiedDbName; } From ee7aad07cc79709b302571bdbc1f9b8e4de67e36 Mon Sep 17 00:00:00 2001 From: morrySnow Date: Fri, 2 Sep 2022 23:59:37 +0800 Subject: [PATCH 8/8] handle db name changed --- .../src/main/java/org/apache/doris/catalog/Database.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java index 1017969955da01..0229551cc78047 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java @@ -193,6 +193,9 @@ public void setNameWithLock(String newName) { writeLock(); try { this.fullQualifiedName = newName; + for (Table table : idToTable.values()) { + table.setQualifiedDbName(fullQualifiedName); + } } finally { writeUnlock(); } @@ -653,6 +656,9 @@ public String getAttachDb() { public void setName(String name) { this.fullQualifiedName = name; + for (Table table : nameToTable.values()) { + table.setQualifiedDbName(name); + } } public synchronized void addFunction(Function function) throws UserException {