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 33e0ec7d3c8 [opt](Nereids) optimize view related capabilities (#51028)
33e0ec7d3c8 is described below
commit 33e0ec7d3c874755ac0bd0b3d9c75efc8374f7ba
Author: morrySnow <[email protected]>
AuthorDate: Fri May 23 16:45:25 2025 +0800
[opt](Nereids) optimize view related capabilities (#51028)
### What problem does this PR solve?
Problem Summary:
- Checking for output columns with the same name has no obvious
benefits, while bringing inconvenience in usage.
- When query a view, should return view's column and table info in
metadata's original-wise fields.
This PR:
- do not check output columns with the same name from inline view or CTE
any more
- remove useless variable interalName in SlotReference intro by #25627
- add two variables in SlotReference to save info of view
- return view's info if present when return metadata of query
### Release note
use correct metadata when query view
---
.../antlr4/org/apache/doris/nereids/DorisParser.g4 | 8 +-
.../main/java/org/apache/doris/alter/Alter.java | 9 +-
.../java/org/apache/doris/mtmv/MTMVPlanUtil.java | 4 +-
.../org/apache/doris/nereids/NereidsPlanner.java | 4 +-
.../apache/doris/nereids/analyzer/MappingSlot.java | 5 -
.../apache/doris/nereids/analyzer/UnboundSlot.java | 5 -
.../org/apache/doris/nereids/cost/CostModelV1.java | 8 +-
.../glue/translator/ExpressionTranslator.java | 4 +-
.../glue/translator/PhysicalPlanTranslator.java | 4 +-
.../glue/translator/PlanTranslatorContext.java | 4 +-
.../nereids/load/NereidsLoadPlanInfoCollector.java | 2 +-
.../doris/nereids/parser/LogicalPlanBuilder.java | 9 +-
.../processor/post/RuntimeFilterPruner.java | 4 +-
.../doris/nereids/rules/analysis/AnalyzeCTE.java | 2 -
.../nereids/rules/analysis/BindExpression.java | 18 +--
.../doris/nereids/rules/analysis/BindRelation.java | 4 +-
.../mv/AbstractMaterializedViewAggregateRule.java | 4 +-
.../exploration/mv/MaterializedViewUtils.java | 13 +-
.../rules/expression/QueryColumnCollector.java | 4 +-
.../nereids/rules/expression/rules/AddMinMax.java | 2 +-
.../rules/implementation/AggregateStrategies.java | 36 ++---
.../LogicalOlapScanToPhysicalOlapScan.java | 8 +-
...ogicalPartitionTopNToPhysicalPartitionTopN.java | 2 +-
.../nereids/rules/rewrite/CheckPrivileges.java | 4 +-
.../nereids/rules/rewrite/ForeignKeyContext.java | 8 +-
.../rewrite/PushDownFilterIntoSchemaScan.java | 2 +-
.../nereids/rules/rewrite/SetPreAggStatus.java | 18 +--
.../rules/rewrite/UnequalPredicateInfer.java | 6 +-
.../rules/rewrite/VariantSubPathPruning.java | 10 +-
.../doris/nereids/stats/FilterEstimation.java | 8 +-
.../doris/nereids/stats/StatsCalculator.java | 8 +-
.../doris/nereids/trees/expressions/Alias.java | 26 +--
.../trees/expressions/ArrayItemReference.java | 3 +-
.../nereids/trees/expressions/Expression.java | 6 +-
.../doris/nereids/trees/expressions/Slot.java | 8 +-
.../nereids/trees/expressions/SlotReference.java | 152 +++++++++---------
.../trees/expressions/functions/agg/AnyValue.java | 2 +-
.../trees/plans/commands/AddConstraintCommand.java | 4 +-
.../commands/CreateMaterializedViewCommand.java | 4 +-
.../trees/plans/commands/CreateTableCommand.java | 4 +-
.../trees/plans/commands/DeleteFromCommand.java | 4 +-
.../trees/plans/commands/info/AlterViewInfo.java | 10 +-
.../trees/plans/commands/info/CreateViewInfo.java | 3 +-
.../trees/plans/logical/LogicalCTEConsumer.java | 7 +-
.../plans/logical/LogicalCatalogRelation.java | 2 +-
.../trees/plans/logical/LogicalOlapScan.java | 2 +-
.../nereids/trees/plans/logical/LogicalView.java | 16 +-
.../plans/physical/PhysicalCatalogRelation.java | 2 +-
.../org/apache/doris/nereids/util/PlanUtils.java | 4 +-
.../org/apache/doris/qe/PointQueryExecutor.java | 2 +-
.../java/org/apache/doris/qe/StmtExecutor.java | 8 +-
.../apache/doris/statistics/AnalysisManager.java | 4 +-
.../org/apache/doris/statistics/Statistics.java | 2 +-
.../doris/statistics/hbo/ScanPlanStatistics.java | 4 +-
.../org/apache/doris/mtmv/MTMVPlanUtilTest.java | 4 +-
.../nereids/jobs/cascades/DeriveStatsJobTest.java | 5 +-
.../rules/analysis/AnalyzeWhereSubqueryTest.java | 4 +-
.../expression/ExpressionRewriteTestHelper.java | 2 +-
.../rules/rewrite/EliminateGroupByTest.java | 2 +-
.../doris/nereids/stats/StatsCalculatorTest.java | 10 +-
.../doris/nereids/trees/plans/ConstraintTest.java | 4 +-
.../org/apache/doris/qe/OlapQueryCacheTest.java | 16 ++
.../doris/statistics/AnalysisManagerTest.java | 7 +-
.../data/ddl_p0/test_create_or_replace_view.out | Bin 505 -> 605 bytes
.../tpcds_sf100/noStatsRfPrune/query24.out | Bin 3152 -> 3122 bytes
.../tpcds_sf100/noStatsRfPrune/query6.out | Bin 3007 -> 2984 bytes
.../tpcds_sf100/no_stats_shape/query24.out | Bin 3308 -> 3278 bytes
.../tpcds_sf100/no_stats_shape/query6.out | Bin 3217 -> 3194 bytes
.../shape_check/tpcds_sf100/rf_prune/query24.out | Bin 3152 -> 3122 bytes
.../shape_check/tpcds_sf100/rf_prune/query6.out | Bin 3256 -> 3233 bytes
.../data/shape_check/tpcds_sf100/shape/query24.out | Bin 3307 -> 3277 bytes
.../data/shape_check/tpcds_sf100/shape/query6.out | Bin 3310 -> 3287 bytes
.../tpcds_sf1000/bs_downgrade_shape/query6.out | Bin 3310 -> 3287 bytes
.../data/shape_check/tpcds_sf1000/hint/query24.out | Bin 3465 -> 3435 bytes
.../data/shape_check/tpcds_sf1000/hint/query6.out | Bin 3310 -> 3287 bytes
.../shape_check/tpcds_sf1000/shape/query24.out | Bin 3312 -> 3282 bytes
.../data/shape_check/tpcds_sf1000/shape/query6.out | Bin 3310 -> 3287 bytes
.../shape_check/tpcds_sf10t_orc/shape/query24.out | Bin 3302 -> 3272 bytes
.../shape_check/tpcds_sf10t_orc/shape/query6.out | Bin 3215 -> 3192 bytes
.../data/shape_check/tpch_sf1000/hint/q11.out | Bin 2104 -> 2074 bytes
.../tpch_sf1000/nostats_rf_prune/q11.out | Bin 2197 -> 2167 bytes
.../tpch_sf1000/nostats_rf_prune/q22.out | Bin 1376 -> 1350 bytes
.../data/shape_check/tpch_sf1000/rf_prune/q11.out | Bin 2205 -> 2175 bytes
.../data/shape_check/tpch_sf1000/rf_prune/q22.out | Bin 1313 -> 1287 bytes
.../data/shape_check/tpch_sf1000/shape/q11.out | Bin 2205 -> 2175 bytes
.../data/shape_check/tpch_sf1000/shape/q22.out | Bin 1313 -> 1287 bytes
.../shape_check/tpch_sf1000/shape_no_stats/q11.out | Bin 2197 -> 2167 bytes
.../shape_check/tpch_sf1000/shape_no_stats/q22.out | Bin 1376 -> 1350 bytes
.../ddl_p0/test_create_or_replace_view.groovy | 5 +
.../suites/mysql_compatibility_p0/metadata.groovy | 59 +++++--
.../cte/test_cte_with_duplicate_consumer.groovy | 8 +-
.../fold_constant/fold_constant_by_fe.groovy | 4 +-
.../subquery/test_duplicate_name_in_view.groovy | 175 ---------------------
.../test_convert_median_to_percentile.groovy | 4 +-
.../suites/nereids_syntax_p0/explain.groovy | 5 +-
.../query_p0/cte/query_with_dup_column.groovy | 112 -------------
96 files changed, 334 insertions(+), 598 deletions(-)
diff --git a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
index f26e617314d..2ae8b987f14 100644
--- a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
+++ b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
@@ -249,9 +249,11 @@ dictionaryColumnDef:
supportedAlterStatement
: ALTER SYSTEM alterSystemClause
#alterSystem
| ALTER VIEW name=multipartIdentifier
- ((MODIFY commentSpec) | ((LEFT_PAREN cols=simpleColumnDefs
RIGHT_PAREN)? AS query)) #alterView
- | ALTER CATALOG name=identifier RENAME newName=identifier
#alterCatalogRename
- | ALTER ROLE role=identifierOrText commentSpec
#alterRole
+ (MODIFY commentSpec |
+ (LEFT_PAREN cols=simpleColumnDefs RIGHT_PAREN)?
+ (COMMENT STRING_LITERAL)? AS query)
#alterView
+ | ALTER CATALOG name=identifier RENAME newName=identifier
#alterCatalogRename
+ | ALTER ROLE role=identifierOrText commentSpec
#alterRole
| ALTER STORAGE VAULT name=multipartIdentifier properties=propertyClause
#alterStorageVault
| ALTER WORKLOAD GROUP name=identifierOrText (FOR
computeGroup=identifierOrText)?
properties=propertyClause?
#alterWorkloadGroup
diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java
b/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java
index f4eff9fc005..fffa80da7a3 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java
@@ -855,8 +855,8 @@ public class Alter {
String tableName = dbTableName.getTbl();
View view = (View) db.getTableOrMetaException(tableName,
TableType.VIEW);
- modifyViewDef(db, view, stmt.getInlineViewDef(),
ctx.getSessionVariable().getSqlMode(), stmt.getColumns(),
- stmt.getComment());
+ modifyViewDef(db, view, stmt.getInlineViewDef(),
ctx.getSessionVariable().getSqlMode(),
+ stmt.getColumns(), stmt.getComment());
}
private void modifyViewDef(Database db, View view, String inlineViewDef,
long sqlMode,
@@ -867,14 +867,15 @@ public class Alter {
try {
if (comment != null) {
view.setComment(comment);
- } else {
+ }
+ // when do alter view modify comment, inlineViewDef and
newFullSchema will be empty.
+ if (!Strings.isNullOrEmpty(inlineViewDef)) {
view.setInlineViewDefWithSqlMode(inlineViewDef, sqlMode);
view.setNewFullSchema(newFullSchema);
}
String viewName = view.getName();
db.unregisterTable(viewName);
db.registerTable(view);
-
AlterViewInfo alterViewInfo = new AlterViewInfo(db.getId(),
view.getId(),
inlineViewDef, newFullSchema, sqlMode, comment);
Env.getCurrentEnv().getEditLog().logModifyViewDef(alterViewInfo);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPlanUtil.java
b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPlanUtil.java
index 8158564cd1d..2139d2937a3 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPlanUtil.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPlanUtil.java
@@ -299,8 +299,8 @@ public class MTMVPlanUtil {
DecimalV2Type.class, DecimalV2Type.SYSTEM_DEFAULT);
if (s.isColumnFromTable()) {
// check if external table
- if ((!((SlotReference) s).getTable().isPresent()
- || !((SlotReference)
s).getTable().get().isManagedTable())) {
+ if ((!((SlotReference) s).getOriginalTable().isPresent()
+ || !((SlotReference)
s).getOriginalTable().get().isManagedTable())) {
if (s.getName().equals(partitionCol) ||
distributionColumnNames.contains(s.getName())) {
// String type can not be used in
partition/distributed column
// so we replace it to varchar
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java
index 3281093db8a..6a7f7d8e59d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java
@@ -555,8 +555,8 @@ public class NereidsPlanner extends Planner {
Optional<TableIf> table = Optional.empty();
if (output instanceof SlotReference) {
SlotReference slotReference = (SlotReference) output;
- column = slotReference.getColumn();
- table = slotReference.getTable();
+ column = slotReference.getOneLevelColumn();
+ table = slotReference.getOneLevelTable();
}
columnLabels.add(output.getName());
FieldInfo fieldInfo = new FieldInfo(
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/MappingSlot.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/MappingSlot.java
index 2e9e8419550..76cbb1d42bd 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/MappingSlot.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/MappingSlot.java
@@ -91,11 +91,6 @@ public class MappingSlot extends Slot {
return slot.getDataType();
}
- @Override
- public String getInternalName() {
- return slot.getInternalName();
- }
-
@Override
public Slot withName(String name) {
return this;
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundSlot.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundSlot.java
index 227aefa1c64..3c5608f4f28 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundSlot.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundSlot.java
@@ -75,11 +75,6 @@ public class UnboundSlot extends Slot implements Unbound,
PropagateNullable {
return nameParts.subList(0, nameParts.size() - 1);
}
- @Override
- public String getInternalName() {
- return getName();
- }
-
@Override
public String computeToSql() {
switch (nameParts.size()) {
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/cost/CostModelV1.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/cost/CostModelV1.java
index ee96cf55b22..09e4d7e6773 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/cost/CostModelV1.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/cost/CostModelV1.java
@@ -166,12 +166,12 @@ class CostModelV1 extends PlanVisitor<Cost, PlanContext> {
boolean hasSlot = compare.left() instanceof SlotReference ||
compare.right() instanceof SlotReference;
if (hasSlot && hasLiteral) {
if (compare.left() instanceof SlotReference) {
- if (((SlotReference)
compare.left()).getColumn().isPresent()) {
- columns.add(((SlotReference)
compare.left()).getColumn().get());
+ if (((SlotReference)
compare.left()).getOriginalColumn().isPresent()) {
+ columns.add(((SlotReference)
compare.left()).getOriginalColumn().get());
}
} else {
- if (((SlotReference)
compare.right()).getColumn().isPresent()) {
- columns.add(((SlotReference)
compare.right()).getColumn().get());
+ if (((SlotReference)
compare.right()).getOriginalColumn().isPresent()) {
+ columns.add(((SlotReference)
compare.right()).getOriginalColumn().get());
}
}
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/ExpressionTranslator.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/ExpressionTranslator.java
index e592fd09f49..f8958e55651 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/ExpressionTranslator.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/ExpressionTranslator.java
@@ -197,7 +197,7 @@ public class ExpressionTranslator extends
DefaultExpressionVisitor<Expr, PlanTra
}
private OlapTable getOlapTableDirectly(SlotReference slot) {
- return slot.getTable()
+ return slot.getOriginalTable()
.filter(OlapTable.class::isInstance)
.map(OlapTable.class::cast)
.orElse(null);
@@ -219,7 +219,7 @@ public class ExpressionTranslator extends
DefaultExpressionVisitor<Expr, PlanTra
.orElseThrow(() -> new AnalysisException(
"No SlotReference found in Match, SQL is "
+ match.toSql()));
- Column column = slot.getColumn()
+ Column column = slot.getOriginalColumn()
.orElseThrow(() -> new AnalysisException(
"SlotReference in Match failed to get
Column, SQL is " + match.toSql()));
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 cb7dd96df79..c9ed13d4637 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
@@ -821,8 +821,8 @@ public class PhysicalPlanTranslator extends
DefaultPlanVisitor<PlanFragment, Pla
if (context.getSessionVariable() != null &&
context.getSessionVariable().forbidUnknownColStats) {
for (int i = 0; i < slots.size(); i++) {
SlotReference slot = (SlotReference) slots.get(i);
- boolean inVisibleCol = slot.getColumn().isPresent()
- && StatisticConstants.shouldIgnoreCol(olapTable,
slot.getColumn().get());
+ boolean inVisibleCol = slot.getOriginalColumn().isPresent()
+ && StatisticConstants.shouldIgnoreCol(olapTable,
slot.getOriginalColumn().get());
if
(olapScan.getStats().findColumnStatistics(slot).isUnKnown()
&& !isComplexDataType(slot.getDataType())
&& !StatisticConstants.isSystemTable(olapTable)
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 f6320383dea..de7fa61422b 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
@@ -286,7 +286,7 @@ public class PlanTranslatorContext {
@Nullable TableIf table) {
SlotDescriptor slotDescriptor = this.addSlotDesc(tupleDesc);
// Only the SlotDesc that in the tuple generated for scan node would
have corresponding column.
- Optional<Column> column = slotReference.getColumn();
+ Optional<Column> column = slotReference.getOriginalColumn();
column.ifPresent(slotDescriptor::setColumn);
slotDescriptor.setType(slotReference.getDataType().toCatalogDataType());
slotDescriptor.setIsMaterialized(true);
@@ -299,7 +299,7 @@ public class PlanTranslatorContext {
slotDescriptor.setLabel(slotReference.getName());
} else {
slotRef = new SlotRef(slotDescriptor);
- if (slotReference.hasSubColPath() &&
slotReference.getColumn().isPresent()) {
+ if (slotReference.hasSubColPath() &&
slotReference.getOriginalColumn().isPresent()) {
slotDescriptor.setSubColLables(slotReference.getSubPath());
// use lower case name for variant's root, since backend treat
parent column as lower case
// see issue:
https://github.com/apache/doris/pull/32999/commits
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/load/NereidsLoadPlanInfoCollector.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/load/NereidsLoadPlanInfoCollector.java
index 153c69bbd7f..562dfe81757 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/load/NereidsLoadPlanInfoCollector.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/load/NereidsLoadPlanInfoCollector.java
@@ -304,7 +304,7 @@ public class NereidsLoadPlanInfoCollector extends
DefaultPlanVisitor<Void, PlanT
for (int i = 0; i < targetTableSlots.size(); ++i) {
if (targetTableSlots.get(i).isColumnFromTable()) {
SlotDescriptor srcSlot = srcSlots
- .get(((SlotReference)
targetTableSlots.get(i)).getColumn().get().getName());
+ .get(((SlotReference)
targetTableSlots.get(i)).getOriginalColumn().get().getName());
if (srcSlot != null) {
loadPlanInfo.destSlotIdToSrcSlotIdWithoutTrans.put(destSlots.get(i).getId(),
srcSlot.getId());
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
index 4d8e4df4f29..4992f880395 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
@@ -1166,8 +1166,7 @@ public class LogicalPlanBuilder extends
DorisParserBaseVisitor<Object> {
@Override
public String visitCommentSpec(DorisParser.CommentSpecContext ctx) {
String commentSpec = ctx == null ? "''" :
ctx.STRING_LITERAL().getText();
- return
-
LogicalPlanBuilderAssistant.escapeBackSlash(commentSpec.substring(1,
commentSpec.length() - 1));
+ return
LogicalPlanBuilderAssistant.escapeBackSlash(commentSpec.substring(1,
commentSpec.length() - 1));
}
/**
@@ -1571,7 +1570,11 @@ public class LogicalPlanBuilder extends
DorisParserBaseVisitor<Object> {
info = new AlterViewInfo(new TableNameInfo(nameParts), comment);
} else {
String querySql = getOriginSql(ctx.query());
- info = new AlterViewInfo(new TableNameInfo(nameParts), querySql,
+ if (ctx.STRING_LITERAL() != null) {
+ comment = ctx.STRING_LITERAL().getText();
+ comment =
LogicalPlanBuilderAssistant.escapeBackSlash(comment.substring(1,
comment.length() - 1));
+ }
+ info = new AlterViewInfo(new TableNameInfo(nameParts), comment,
querySql,
ctx.cols == null ? Lists.newArrayList() :
visitSimpleColumnDefs(ctx.cols));
}
return new AlterViewCommand(info);
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterPruner.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterPruner.java
index 884349da69c..51a9003b78f 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterPruner.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterPruner.java
@@ -189,8 +189,8 @@ public class RuntimeFilterPruner extends PlanPostProcessor {
private boolean isVisibleColumn(Slot slot) {
if (slot instanceof SlotReference) {
SlotReference slotReference = (SlotReference) slot;
- if (slotReference.getColumn().isPresent()) {
- return slotReference.getColumn().get().isVisible();
+ if (slotReference.getOriginalColumn().isPresent()) {
+ return slotReference.getOriginalColumn().get().isVisible();
}
}
return true;
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/AnalyzeCTE.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/AnalyzeCTE.java
index 36a0459375b..129b0860a74 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/AnalyzeCTE.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/AnalyzeCTE.java
@@ -101,8 +101,6 @@ public class AnalyzeCTE extends OneAnalysisRuleFactory {
CTEId cteId = StatementScopeIdGenerator.newCTEId();
LogicalSubQueryAlias<Plan> logicalSubQueryAlias =
aliasQuery.withChildren(ImmutableList.of(analyzedCtePlan));
-
BindExpression.checkSameNameSlot(logicalSubQueryAlias.child(0).getOutput(),
- logicalSubQueryAlias.getAlias());
outerCteCtx = new CTEContext(cteId, logicalSubQueryAlias,
outerCteCtx);
outerCteCtx.setAnalyzedPlan(logicalSubQueryAlias);
cteProducerPlans.add(new LogicalCTEProducer<>(cteId,
logicalSubQueryAlias));
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindExpression.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindExpression.java
index 3b804d7cf2b..c3ae8116067 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindExpression.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindExpression.java
@@ -252,9 +252,7 @@ public class BindExpression implements AnalysisRuleFactory {
}
private LogicalSubQueryAlias<Plan>
bindSubqueryAlias(MatchingContext<LogicalSubQueryAlias<Plan>> ctx) {
- LogicalSubQueryAlias<Plan> subQueryAlias = ctx.root;
- checkSameNameSlot(subQueryAlias.child(0).getOutput(),
subQueryAlias.getAlias());
- return subQueryAlias;
+ return ctx.root;
}
private LogicalPlan bindGenerate(MatchingContext<LogicalGenerate<Plan>>
ctx) {
@@ -1315,20 +1313,6 @@ public class BindExpression implements
AnalysisRuleFactory {
return new LogicalTVFRelation(unboundTVFRelation.getRelationId(),
(TableValuedFunction) bindResult.first);
}
- /**
- * Check the slot in childOutputs is duplicated or not
- * If childOutputs has duplicated column name, would throw analysis
exception
- */
- public static void checkSameNameSlot(List<Slot> childOutputs, String
subQueryAlias) {
- Set<String> nameSlots = new HashSet<>(childOutputs.size() * 2);
- for (Slot s : childOutputs) {
- if (!nameSlots.add(s.getInternalName())) {
- throw new AnalysisException("Duplicated inline view column
alias: '" + s.getName()
- + "'" + " in inline view: '" + subQueryAlias + "'");
- }
- }
- }
-
private void
checkIfOutputAliasNameDuplicatedForGroupBy(Collection<Expression> expressions,
List<? extends NamedExpression> output) {
// if group_by_and_having_use_alias_first=true, we should fall back to
original planner until we
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 02a244571e2..27569c1fef9 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
@@ -266,10 +266,10 @@ public class BindRelation extends OneAnalysisRuleFactory {
for (Column col : columns) {
// use exist slot in the plan
- SlotReference slot = SlotReference.fromColumn(olapTable, col,
col.getName(), olapScan.qualified());
+ SlotReference slot = SlotReference.fromColumn(olapTable, col,
olapScan.qualified());
ExprId exprId = slot.getExprId();
for (Slot childSlot : childOutputSlots) {
- if (childSlot instanceof SlotReference && ((SlotReference)
childSlot).getName().equals(col.getName())) {
+ if (childSlot instanceof SlotReference &&
childSlot.getName().equals(col.getName())) {
exprId = childSlot.getExprId();
slot = slot.withExprId(exprId);
break;
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AbstractMaterializedViewAggregateRule.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AbstractMaterializedViewAggregateRule.java
index fd2b5b4b8aa..452b791f7f2 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AbstractMaterializedViewAggregateRule.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AbstractMaterializedViewAggregateRule.java
@@ -364,9 +364,9 @@ public abstract class AbstractMaterializedViewAggregateRule
extends AbstractMate
for (Expression expression : groupByShuttledExpressions) {
canUnionRewrite = !expression.collectToSet(expr -> expr instanceof
SlotReference
&& ((SlotReference) expr).isColumnFromTable()
- && Objects.equals(((SlotReference)
expr).getColumn().map(Column::getName).orElse(null),
+ && Objects.equals(((SlotReference)
expr).getOriginalColumn().map(Column::getName).orElse(null),
relatedCol)
- && Objects.equals(((SlotReference)
expr).getTable().map(BaseTableInfo::new).orElse(null),
+ && Objects.equals(((SlotReference)
expr).getOriginalTable().map(BaseTableInfo::new).orElse(null),
relatedTableInfo)).isEmpty();
if (canUnionRewrite) {
break;
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/MaterializedViewUtils.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/MaterializedViewUtils.java
index 74cc21e0342..e642cc7cb6e 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/MaterializedViewUtils.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/MaterializedViewUtils.java
@@ -385,13 +385,13 @@ public class MaterializedViewUtils {
Set<Column> leftColumnSet = left.getOutputSet().stream()
.filter(slot -> slot instanceof SlotReference
&& slot.isColumnFromTable())
- .map(slot -> ((SlotReference) slot).getColumn().get())
+ .map(slot -> ((SlotReference)
slot).getOriginalColumn().get())
.collect(Collectors.toSet());
SlotReference contextPartitionColumn =
getContextPartitionColumn(context);
if (contextPartitionColumn == null) {
return null;
}
- boolean useLeft =
leftColumnSet.contains(contextPartitionColumn.getColumn().get());
+ boolean useLeft =
leftColumnSet.contains(contextPartitionColumn.getOriginalColumn().get());
JoinType joinType = join.getJoinType();
if (joinType.isInnerJoin() || joinType.isCrossJoin()) {
return visit(join, context);
@@ -424,7 +424,8 @@ public class MaterializedViewUtils {
}
// Check the table which mv partition column belonged to is same
as the current check relation or not
if (!((LogicalCatalogRelation)
relation).getTable().getFullQualifiers().equals(
-
contextPartitionColumn.getTable().map(TableIf::getFullQualifiers).orElse(ImmutableList.of())))
{
+ contextPartitionColumn.getOriginalTable()
+
.map(TableIf::getFullQualifiers).orElse(ImmutableList.of()))) {
context.addFailReason(String.format("mv partition column name
is not belonged to current check , "
+ "table, current table is %s",
((LogicalCatalogRelation)
relation).getTable().getFullQualifiers()));
@@ -459,7 +460,7 @@ public class MaterializedViewUtils {
}
Set<Column> partitionColumnSet = new HashSet<>(
relatedTable.getPartitionColumns(MvccUtil.getSnapshotFromContext(relatedTable)));
- Column mvReferenceColumn =
contextPartitionColumn.getColumn().get();
+ Column mvReferenceColumn =
contextPartitionColumn.getOriginalColumn().get();
Expr definExpr = mvReferenceColumn.getDefineExpr();
if (definExpr instanceof SlotRef) {
Column referenceRollupColumn = ((SlotRef)
definExpr).getColumn();
@@ -534,14 +535,14 @@ public class MaterializedViewUtils {
Set<Column> originalPartitionbyExprSet = new HashSet<>();
partitionKeys.forEach(groupExpr -> {
if (groupExpr instanceof SlotReference &&
groupExpr.isColumnFromTable()) {
- originalPartitionbyExprSet.add(((SlotReference)
groupExpr).getColumn().get());
+ originalPartitionbyExprSet.add(((SlotReference)
groupExpr).getOriginalColumn().get());
}
});
SlotReference contextPartitionColumn =
getContextPartitionColumn(context);
if (contextPartitionColumn == null) {
return false;
}
- if
(!originalPartitionbyExprSet.contains(contextPartitionColumn.getColumn().get()))
{
+ if
(!originalPartitionbyExprSet.contains(contextPartitionColumn.getOriginalColumn().get()))
{
return false;
}
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/QueryColumnCollector.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/QueryColumnCollector.java
index 1aa81c36d9a..bc1670221a7 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/QueryColumnCollector.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/QueryColumnCollector.java
@@ -193,8 +193,8 @@ public class QueryColumnCollector extends
DefaultPlanRewriter<CollectorContext>
path.add(slot);
if (slot instanceof SlotReference) {
SlotReference slotReference = (SlotReference) slot;
- Optional<Column> col = slotReference.getColumn();
- Optional<TableIf> table = slotReference.getTable();
+ Optional<Column> col = slotReference.getOriginalColumn();
+ Optional<TableIf> table = slotReference.getOriginalTable();
if (col.isPresent() && table.isPresent()) {
return Collections.singleton(slot);
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/AddMinMax.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/AddMinMax.java
index 1ac5ea851cf..e3ea1a43b3a 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/AddMinMax.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/AddMinMax.java
@@ -277,7 +277,7 @@ public class AddMinMax implements
ExpressionPatternRuleFactory {
}
private boolean isExprNeedAddMinMax(Expression expr) {
- return (expr instanceof SlotReference) && ((SlotReference)
expr).getColumn().isPresent();
+ return (expr instanceof SlotReference) && ((SlotReference)
expr).getOriginalColumn().isPresent();
}
private Map<Expression, MinMaxValue> getExprMinMaxValues(ValueDesc value) {
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java
index fa511631fc6..2208e94506d 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java
@@ -188,7 +188,7 @@ public class AggregateStrategies implements
ImplementationRuleFactory {
}
Expression childExpr =
filter.getConjuncts().iterator().next().children().get(0);
if (childExpr instanceof SlotReference) {
- Optional<Column> column =
((SlotReference) childExpr).getColumn();
+ Optional<Column> column =
((SlotReference) childExpr).getOriginalColumn();
return
column.map(Column::isDeleteSignColumn).orElse(false);
}
return false;
@@ -210,23 +210,19 @@ public class AggregateStrategies implements
ImplementationRuleFactory {
})
),
RuleType.STORAGE_LAYER_AGGREGATE_MINMAX_ON_UNIQUE.build(
- logicalAggregate(
- logicalProject(
- logicalFilter(
-
logicalOlapScan().when(this::isUniqueKeyTable))
- .when(filter -> {
- if
(filter.getConjuncts().size() != 1) {
- return false;
- }
- Expression childExpr =
filter.getConjuncts().iterator().next()
- .children().get(0);
- if (childExpr instanceof
SlotReference) {
- Optional<Column> column =
((SlotReference) childExpr).getColumn();
- return
column.map(Column::isDeleteSignColumn).orElse(false);
- }
- return false;
- }))
- )
+
logicalAggregate(logicalProject(logicalFilter(logicalOlapScan().when(this::isUniqueKeyTable))
+ .when(filter -> {
+ if (filter.getConjuncts().size() != 1) {
+ return false;
+ }
+ Expression childExpr =
filter.getConjuncts().iterator().next()
+ .children().get(0);
+ if (childExpr instanceof SlotReference) {
+ Optional<Column> column = ((SlotReference)
childExpr).getOriginalColumn();
+ return
column.map(Column::isDeleteSignColumn).orElse(false);
+ }
+ return false;
+ })))
.when(agg -> enablePushDownMinMaxOnUnique())
.when(agg -> agg.getGroupByExpressions().isEmpty())
.when(agg -> {
@@ -687,7 +683,7 @@ public class AggregateStrategies implements
ImplementationRuleFactory {
SlotReference.class::isInstance);
List<SlotReference> usedSlotInTable = (List<SlotReference>)
Project.findProject(aggUsedSlots, outPutSlots);
for (SlotReference slot : usedSlotInTable) {
- Column column = slot.getColumn().get();
+ Column column = slot.getOriginalColumn().get();
PrimitiveType colType = column.getType().getPrimitiveType();
if (colType.isComplexType() || colType.isHllType() ||
colType.isBitmapType()) {
return false;
@@ -821,7 +817,7 @@ public class AggregateStrategies implements
ImplementationRuleFactory {
logicalScan.getOutput());
for (SlotReference slot : usedSlotInTable) {
- Column column = slot.getColumn().get();
+ Column column = slot.getOriginalColumn().get();
if (column.isAggregated()) {
return canNotPush;
}
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 4d006e557ac..a7aa4ebc6e3 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
@@ -86,7 +86,7 @@ public class LogicalOlapScanToPhysicalOlapScan extends
OneImplementationRuleFact
List<ExprId> hashColumns = Lists.newArrayList();
for (Column column :
hashDistributionInfo.getDistributionColumns()) {
for (Slot slot : output) {
- if (((SlotReference)
slot).getColumn().get().getNameWithoutMvPrefix()
+ if (((SlotReference)
slot).getOriginalColumn().get().getNameWithoutMvPrefix()
.equals(column.getName())) {
hashColumns.add(slot.getExprId());
}
@@ -98,7 +98,8 @@ public class LogicalOlapScanToPhysicalOlapScan extends
OneImplementationRuleFact
// If the length of the column in the bucket key
changes after DDL, the length cannot be
// determined. As a result, some bucket fields are
lost in the query execution plan.
// So here we use the column name to avoid this
problem
- if (((SlotReference)
slot).getColumn().get().getName().equalsIgnoreCase(column.getName())) {
+ if (((SlotReference)
slot).getOriginalColumn().get().getName()
+ .equalsIgnoreCase(column.getName())) {
hashColumns.add(slot.getExprId());
}
}
@@ -115,7 +116,8 @@ public class LogicalOlapScanToPhysicalOlapScan extends
OneImplementationRuleFact
// If the length of the column in the bucket key
changes after DDL, the length cannot be
// determined. As a result, some bucket fields are
lost in the query execution plan.
// So here we use the column name to avoid this problem
- if (((SlotReference)
slot).getColumn().get().getName().equalsIgnoreCase(column.getName())) {
+ if (((SlotReference)
slot).getOriginalColumn().get().getName()
+ .equalsIgnoreCase(column.getName())) {
hashColumns.add(slot.getExprId());
}
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/LogicalPartitionTopNToPhysicalPartitionTopN.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/LogicalPartitionTopNToPhysicalPartitionTopN.java
index 410e68f3ec2..7af0ebca511 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/LogicalPartitionTopNToPhysicalPartitionTopN.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/LogicalPartitionTopNToPhysicalPartitionTopN.java
@@ -159,7 +159,7 @@ public class LogicalPartitionTopNToPhysicalPartitionTopN
extends OneImplementati
return false;
} else {
SlotReference slot = (SlotReference) expr;
- if (!slot.getColumn().isPresent() ||
!slot.getTable().isPresent()) {
+ if (!slot.getOriginalColumn().isPresent() ||
!slot.getOriginalTable().isPresent()) {
return false;
}
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CheckPrivileges.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CheckPrivileges.java
index ebef2ecea21..8cb24cceb09 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CheckPrivileges.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CheckPrivileges.java
@@ -96,8 +96,8 @@ public class CheckPrivileges extends ColumnPruning {
Slot slot = idToSlot.get(requiredSlot.getExprId().asInt());
if (slot != null) {
// don't check privilege for hidden column, e.g.
__DORIS_DELETE_SIGN__
- if (slot instanceof SlotReference && ((SlotReference)
slot).getColumn().isPresent()
- && !((SlotReference)
slot).getColumn().get().isVisible()) {
+ if (slot instanceof SlotReference && ((SlotReference)
slot).getOriginalColumn().isPresent()
+ && !((SlotReference)
slot).getOriginalColumn().get().isVisible()) {
continue;
}
usedColumns.add(slot.getName());
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/ForeignKeyContext.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/ForeignKeyContext.java
index 776f2697c89..52021622ff8 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/ForeignKeyContext.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/ForeignKeyContext.java
@@ -123,10 +123,10 @@ public class ForeignKeyContext {
}
void putSlot(SlotReference slot) {
- if (!slot.getColumn().isPresent()) {
+ if (!slot.getOriginalColumn().isPresent()) {
return;
}
- Column c = slot.getColumn().get();
+ Column c = slot.getOriginalColumn().get();
slotToColumn.put(slot, c);
}
@@ -139,8 +139,8 @@ public class ForeignKeyContext {
private boolean isHiddenConjunct(Expression expression) {
for (Slot slot : expression.getInputSlots()) {
if (slot instanceof SlotReference
- && ((SlotReference) slot).getColumn().isPresent()
- && ((SlotReference)
slot).getColumn().get().isDeleteSignColumn()) {
+ && ((SlotReference) slot).getOriginalColumn().isPresent()
+ && ((SlotReference)
slot).getOriginalColumn().get().isDeleteSignColumn()) {
return true;
}
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PushDownFilterIntoSchemaScan.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PushDownFilterIntoSchemaScan.java
index d8ab4cf62a9..2f2ab47b75d 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PushDownFilterIntoSchemaScan.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PushDownFilterIntoSchemaScan.java
@@ -52,7 +52,7 @@ public class PushDownFilterIntoSchemaScan extends
OneRewriteRuleFactory {
if (!(slot instanceof SlotReference)) {
continue;
}
- Optional<Column> column = ((SlotReference) slot).getColumn();
+ Optional<Column> column = ((SlotReference)
slot).getOriginalColumn();
if (!column.isPresent()) {
continue;
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/SetPreAggStatus.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/SetPreAggStatus.java
index 77b1a357370..fad3e02c0cf 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/SetPreAggStatus.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/SetPreAggStatus.java
@@ -295,12 +295,12 @@ public class SetPreAggStatus extends
DefaultPlanRewriter<Stack<SetPreAggStatus.P
} else if (aggFunc.children().size() == 1 && aggFunc.child(0)
instanceof Slot) {
Slot aggSlot = (Slot) aggFunc.child(0);
if (aggSlot instanceof SlotReference
- && ((SlotReference)
aggSlot).getColumn().isPresent()) {
- if (((SlotReference)
aggSlot).getColumn().get().isKey()) {
+ && ((SlotReference)
aggSlot).getOriginalColumn().isPresent()) {
+ if (((SlotReference)
aggSlot).getOriginalColumn().get().isKey()) {
preAggStatus =
OneKeySlotAggChecker.INSTANCE.check(aggFunc);
} else {
preAggStatus =
OneValueSlotAggChecker.INSTANCE.check(aggFunc,
- ((SlotReference)
aggSlot).getColumn().get().getAggregationType());
+ ((SlotReference)
aggSlot).getOriginalColumn().get().getAggregationType());
}
} else {
preAggStatus = PreAggStatus.off(
@@ -323,8 +323,8 @@ public class SetPreAggStatus extends
DefaultPlanRewriter<Stack<SetPreAggStatus.P
Set<SlotReference> keySlots =
com.google.common.collect.Sets.newHashSetWithExpectedSize(slots.size());
Set<SlotReference> valueSlots =
com.google.common.collect.Sets.newHashSetWithExpectedSize(slots.size());
for (Slot slot : slots) {
- if (slot instanceof SlotReference && ((SlotReference)
slot).getColumn().isPresent()) {
- if (((SlotReference) slot).getColumn().get().isKey()) {
+ if (slot instanceof SlotReference && ((SlotReference)
slot).getOriginalColumn().isPresent()) {
+ if (((SlotReference)
slot).getOriginalColumn().get().isKey()) {
keySlots.add((SlotReference) slot);
} else {
valueSlots.add((SlotReference) slot);
@@ -577,14 +577,14 @@ public class SetPreAggStatus extends
DefaultPlanRewriter<Stack<SetPreAggStatus.P
private boolean isKeySlot(Expression expression) {
return expression instanceof SlotReference
- && ((SlotReference) expression).getColumn().isPresent()
- && ((SlotReference)
expression).getColumn().get().isKey();
+ && ((SlotReference)
expression).getOriginalColumn().isPresent()
+ && ((SlotReference)
expression).getOriginalColumn().get().isKey();
}
private boolean isAggTypeMatched(Expression expression,
AggregateType aggregateType) {
return expression instanceof SlotReference
- && ((SlotReference) expression).getColumn().isPresent()
- && ((SlotReference) expression).getColumn().get()
+ && ((SlotReference)
expression).getOriginalColumn().isPresent()
+ && ((SlotReference)
expression).getOriginalColumn().get()
.getAggregationType() == aggregateType;
}
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/UnequalPredicateInfer.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/UnequalPredicateInfer.java
index 83209d6691c..cab3350c89b 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/UnequalPredicateInfer.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/UnequalPredicateInfer.java
@@ -274,14 +274,14 @@ public class UnequalPredicateInfer {
if (!checkSlot.isColumnFromTable()) {
return false;
}
- Column column = checkSlot.getColumn().get();
+ Column column = checkSlot.getOriginalColumn().get();
if (column.isKey()) {
return true;
}
- if (!checkSlot.getTable().isPresent()) {
+ if (!checkSlot.getOriginalTable().isPresent()) {
return false;
}
- TableIf tableIf = checkSlot.getTable().get();
+ TableIf tableIf = checkSlot.getOriginalTable().get();
if (tableIf.isPartitionedTable() &&
tableIf.isPartitionColumn(column.getName())) {
return true;
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/VariantSubPathPruning.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/VariantSubPathPruning.java
index 414dac1c95d..d6ea99aa496 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/VariantSubPathPruning.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/VariantSubPathPruning.java
@@ -69,7 +69,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Optional;
import java.util.Set;
/**
@@ -192,8 +191,8 @@ public class VariantSubPathPruning extends
DefaultPlanRewriter<PruneContext> imp
if (slot.getDataType() instanceof VariantType
&&
context.slotToSubPathsMap.containsKey((SlotReference) slot)) {
Set<List<String>> subPaths =
context.slotToSubPathsMap.get(slot);
- if (((SlotReference) slot).getColumn().isPresent()) {
- colToSubPaths.put(((SlotReference)
slot).getColumn().get().getName(), subPaths);
+ if (((SlotReference)
slot).getOriginalColumn().isPresent()) {
+ colToSubPaths.put(((SlotReference)
slot).getOriginalColumn().get().getName(), subPaths);
}
}
}
@@ -308,10 +307,7 @@ public class VariantSubPathPruning extends
DefaultPlanRewriter<PruneContext> imp
}
SlotReference outputSlot = new
SlotReference(StatementScopeIdGenerator.newExprId(),
entry.getValue().get(0).getName(),
VariantType.INSTANCE,
- true, ImmutableList.of(),
- null,
- null,
- Optional.empty());
+ true, ImmutableList.of());
outputs.add(outputSlot);
// update element to slot map
Map<List<String>, SlotReference> s =
oriSlotToSubPathToSlot.computeIfAbsent(
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/FilterEstimation.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/FilterEstimation.java
index 61f4bc5f203..0be9d8cf1c7 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/FilterEstimation.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/FilterEstimation.java
@@ -169,14 +169,14 @@ public class FilterEstimation extends
ExpressionVisitor<Statistics, EstimationCo
@Override
public Statistics visitComparisonPredicate(ComparisonPredicate cp,
EstimationContext context) {
Expression left = cp.left();
- if (left instanceof SlotReference && ((SlotReference)
left).getColumn().isPresent()) {
- if ("__DORIS_DELETE_SIGN__".equals(((SlotReference)
left).getColumn().get().getName())) {
+ if (left instanceof SlotReference && ((SlotReference)
left).getOriginalColumn().isPresent()) {
+ if ("__DORIS_DELETE_SIGN__".equals(((SlotReference)
left).getOriginalColumn().get().getName())) {
return context.statistics;
}
}
Expression right = cp.right();
- if (right instanceof SlotReference && ((SlotReference)
right).getColumn().isPresent()) {
- if ("__DORIS_DELETE_SIGN__".equals(((SlotReference)
right).getColumn().get().getName())) {
+ if (right instanceof SlotReference && ((SlotReference)
right).getOriginalColumn().isPresent()) {
+ if ("__DORIS_DELETE_SIGN__".equals(((SlotReference)
right).getOriginalColumn().get().getName())) {
return context.statistics;
}
}
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 baa7162b75e..c8578f0810e 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
@@ -597,7 +597,7 @@ public class StatsCalculator extends
DefaultPlanVisitor<Statistics, Void> {
} else {
cache = getColumnStatsFromTableCache((CatalogRelation)
olapScan, slot);
}
- if (slot.getColumn().isPresent()) {
+ if (slot.getOriginalColumn().isPresent()) {
cache = updateMinMaxForPartitionKey(olapTable,
selectedPartitionNames, slot, cache);
}
ColumnStatisticBuilder colStatsBuilder = new
ColumnStatisticBuilder(cache,
@@ -642,7 +642,7 @@ public class StatsCalculator extends
DefaultPlanVisitor<Statistics, Void> {
private ColumnStatistic updateMinMaxForListPartitionKey(OlapTable
olapTable,
List<String> selectedPartitionNames,
SlotReference slot, ColumnStatistic cache) {
- int partitionColumnIdx =
olapTable.getPartitionColumns().indexOf(slot.getColumn().get());
+ int partitionColumnIdx =
olapTable.getPartitionColumns().indexOf(slot.getOriginalColumn().get());
if (partitionColumnIdx != -1) {
try {
LiteralExpr minExpr = null;
@@ -686,7 +686,7 @@ public class StatsCalculator extends
DefaultPlanVisitor<Statistics, Void> {
private ColumnStatistic updateMinMaxForTheFirstRangePartitionKey(OlapTable
olapTable,
List<String> selectedPartitionNames,
SlotReference slot, ColumnStatistic cache) {
- int partitionColumnIdx =
olapTable.getPartitionColumns().indexOf(slot.getColumn().get());
+ int partitionColumnIdx =
olapTable.getPartitionColumns().indexOf(slot.getOriginalColumn().get());
// for multi partition keys, only the first partition key need to
adjust min/max
if (partitionColumnIdx == 0) {
// update partition column min/max by partition info
@@ -777,7 +777,7 @@ public class StatsCalculator extends
DefaultPlanVisitor<Statistics, Void> {
private boolean isVisibleSlotReference(Slot slot) {
if (slot instanceof SlotReference) {
- Optional<Column> colOpt = ((SlotReference) slot).getColumn();
+ Optional<Column> colOpt = ((SlotReference)
slot).getOriginalColumn();
if (colOpt.isPresent()) {
return colOpt.get().isVisible();
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Alias.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Alias.java
index 48a98eb3ee1..5bd08487025 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Alias.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Alias.java
@@ -89,21 +89,12 @@ public class Alias extends NamedExpression implements
UnaryExpression {
public Slot toSlot() throws UnboundException {
SlotReference slotReference = child() instanceof SlotReference
? (SlotReference) child() : null;
-
- Supplier<Optional<String>> internalName = nameFromChild
- ? Suppliers.memoize(() ->
Optional.of(child().toString()))
- : () -> Optional.of(name.get());
return new SlotReference(exprId, name, child().getDataType(),
child().nullable(), qualifier,
- slotReference != null
- ? ((SlotReference) child()).getTable().orElse(null)
- : null,
- slotReference != null
- ? slotReference.getColumn().orElse(null)
- : null,
- internalName,
- slotReference != null
- ? slotReference.getSubPath()
- : ImmutableList.of(), Optional.empty()
+ slotReference != null ? ((SlotReference)
child()).getOriginalTable().orElse(null) : null,
+ slotReference != null ?
slotReference.getOriginalColumn().orElse(null) : null,
+ slotReference != null ? ((SlotReference)
child()).getOneLevelTable().orElse(null) : null,
+ slotReference != null ?
slotReference.getOriginalColumn().orElse(null) : null,
+ slotReference != null ? slotReference.getSubPath() :
ImmutableList.of(), Optional.empty()
);
}
@@ -160,12 +151,7 @@ public class Alias extends NamedExpression implements
UnaryExpression {
@Override
public Alias withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
- if (nameFromChild) {
- return new Alias(exprId, children,
- Suppliers.memoize(() -> children.get(0).toSql()),
qualifier, nameFromChild);
- } else {
- return new Alias(exprId, children, name, qualifier, nameFromChild);
- }
+ return new Alias(exprId, children, name, qualifier, nameFromChild);
}
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/ArrayItemReference.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/ArrayItemReference.java
index eca81d82028..b763d6741ab 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/ArrayItemReference.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/ArrayItemReference.java
@@ -29,7 +29,6 @@ import com.google.common.collect.ImmutableList;
import java.util.List;
import java.util.Objects;
-import java.util.Optional;
/**
* it is item from array, which used in lambda function
@@ -144,7 +143,7 @@ public class ArrayItemReference extends NamedExpression
implements ExpectsInputT
*/
public ArrayItemSlot(ExprId exprId, String name, DataType dataType,
boolean nullable) {
super(exprId, name, dataType, nullable, ImmutableList.of(),
- null, null, Optional.empty(), ImmutableList.of());
+ null, null, null, null, ImmutableList.of());
}
@Override
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Expression.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Expression.java
index 416e1f80c69..21d461c5746 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Expression.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Expression.java
@@ -398,12 +398,12 @@ public abstract class Expression extends
AbstractTreeNode<Expression> implements
}
public boolean isColumnFromTable() {
- return (this instanceof SlotReference) && ((SlotReference)
this).getColumn().isPresent();
+ return (this instanceof SlotReference) && ((SlotReference)
this).getOriginalColumn().isPresent();
}
public boolean isKeyColumnFromTable() {
- return (this instanceof SlotReference) && ((SlotReference)
this).getColumn().isPresent()
- && ((SlotReference) this).getColumn().get().isKey();
+ return (this instanceof SlotReference) && ((SlotReference)
this).getOriginalColumn().isPresent()
+ && ((SlotReference) this).getOriginalColumn().get().isKey();
}
/** containsNullLiteralChildren */
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Slot.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Slot.java
index 40cf360ab46..d2b40ecc2d6 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Slot.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Slot.java
@@ -17,6 +17,8 @@
package org.apache.doris.nereids.trees.expressions;
+import org.apache.doris.catalog.Column;
+import org.apache.doris.catalog.TableIf;
import org.apache.doris.common.Pair;
import org.apache.doris.nereids.trees.expressions.shape.LeafExpression;
import org.apache.doris.nereids.types.DataType;
@@ -56,15 +58,15 @@ public abstract class Slot extends NamedExpression
implements LeafExpression {
throw new RuntimeException("Do not implement");
}
- public Slot withName(String name) {
+ public Slot withOneLevelTableAndColumnAndQualifier(TableIf oneLevelTable,
Column column, List<String> qualifier) {
throw new RuntimeException("Do not implement");
}
- public Slot withExprId(ExprId exprId) {
+ public Slot withName(String name) {
throw new RuntimeException("Do not implement");
}
- public String getInternalName() {
+ public Slot withExprId(ExprId exprId) {
throw new RuntimeException("Do not implement");
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/SlotReference.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/SlotReference.java
index 6da77da0fef..725d1fdf1f1 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/SlotReference.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/SlotReference.java
@@ -26,7 +26,6 @@ import org.apache.doris.nereids.types.DataType;
import org.apache.doris.nereids.util.Utils;
import com.google.common.base.Preconditions;
-import com.google.common.base.Suppliers;
import com.google.common.collect.ImmutableList;
import java.util.List;
@@ -49,48 +48,48 @@ public class SlotReference extends Slot {
// e.g. For accessing variant["a"]["b"], the parsed paths is ["a", "b"]
protected final List<String> subPath;
- // the unique string representation of a SlotReference
- // different SlotReference will have different internalName
- // TODO: remove this member variable after mv selection is refactored
- protected final Supplier<Optional<String>> internalName;
+ // table and column from the original table, fall through views
+ private final TableIf originalTable;
+ private final Column originalColumn;
- private final TableIf table;
- private final Column column;
+ // table and column from one level table/view, do not fall through views.
use for compatible with MySQL protocol
+ // that need return original table and name for view not its original
table if u query a view
+ private final TableIf oneLevelTable;
+ private final Column oneLevelColumn;
public SlotReference(String name, DataType dataType) {
this(StatementScopeIdGenerator.newExprId(), name, dataType, true,
ImmutableList.of(),
- null, null, Optional.empty(), ImmutableList.of());
+ null, null, null, null, ImmutableList.of());
}
public SlotReference(String name, DataType dataType, boolean nullable) {
this(StatementScopeIdGenerator.newExprId(), name, dataType, nullable,
ImmutableList.of(),
- null, null, Optional.empty(), ImmutableList.of());
+ null, null, null, null, ImmutableList.of());
}
public SlotReference(String name, DataType dataType, boolean nullable,
List<String> qualifier) {
this(StatementScopeIdGenerator.newExprId(), name, dataType, nullable,
- qualifier, null, null, Optional.empty(), ImmutableList.of());
+ qualifier, null, null, null, null, ImmutableList.of());
}
public SlotReference(ExprId exprId, String name, DataType dataType,
boolean nullable, List<String> qualifier) {
- this(exprId, name, dataType, nullable, qualifier, null, null,
Optional.empty(), ImmutableList.of());
+ this(exprId, name, dataType, nullable, qualifier, null, null, null,
null, ImmutableList.of());
}
- public SlotReference(ExprId exprId, String name, DataType dataType,
boolean nullable,
- List<String> qualifier, @Nullable TableIf table, @Nullable Column
column) {
- this(exprId, name, dataType, nullable, qualifier, table, column,
Optional.empty(), ImmutableList.of());
+ public SlotReference(ExprId exprId, String name, DataType dataType,
boolean nullable, List<String> qualifier,
+ @Nullable TableIf originalTable, @Nullable Column originalColumn,
+ @Nullable TableIf oneLevelTable, @Nullable Column oneLevelColumn) {
+ this(exprId, name, dataType, nullable, qualifier,
+ originalTable, originalColumn, oneLevelTable, oneLevelColumn,
ImmutableList.of());
}
- public SlotReference(ExprId exprId, String name, DataType dataType,
boolean nullable,
- List<String> qualifier, @Nullable TableIf table, @Nullable Column
column, Optional<String> internalName) {
- this(exprId, name, dataType, nullable, qualifier, table, column,
internalName, ImmutableList.of());
- }
-
- public SlotReference(ExprId exprId, String name, DataType dataType,
boolean nullable,
- List<String> qualifier, @Nullable TableIf table, @Nullable Column
column,
- Optional<String> internalName, List<String> subColLabels) {
- this(exprId, () -> name, dataType, nullable, qualifier, table, column,
- buildInternalName(() -> name, subColLabels, internalName),
subColLabels, Optional.empty());
+ public SlotReference(ExprId exprId, String name, DataType dataType,
boolean nullable, List<String> qualifier,
+ @Nullable TableIf originalTable, @Nullable Column originalColumn,
+ @Nullable TableIf oneLevelTable, @Nullable Column oneLevelColumn,
+ List<String> subPath) {
+ this(exprId, () -> name, dataType, nullable, qualifier,
+ originalTable, originalColumn, oneLevelTable, oneLevelColumn,
+ subPath, Optional.empty());
}
/**
@@ -101,14 +100,13 @@ public class SlotReference extends Slot {
* @param dataType slot reference logical data type
* @param nullable true if nullable
* @param qualifier slot reference qualifier
- * @param column the column which this slot come from
- * @param internalName the internalName of this slot
+ * @param originalColumn the column which this slot come from
* @param subPath subColumn access labels
*/
public SlotReference(ExprId exprId, Supplier<String> name, DataType
dataType, boolean nullable,
- List<String> qualifier, @Nullable TableIf table, @Nullable Column
column,
- Supplier<Optional<String>> internalName, List<String> subPath,
- Optional<Pair<Integer, Integer>> indexInSql) {
+ List<String> qualifier, @Nullable TableIf originalTable, @Nullable
Column originalColumn,
+ @Nullable TableIf oneLevelTable, Column oneLevelColumn,
+ List<String> subPath, Optional<Pair<Integer, Integer>> indexInSql)
{
super(indexInSql);
this.exprId = exprId;
this.name = name;
@@ -116,10 +114,11 @@ public class SlotReference extends Slot {
this.qualifier = Utils.fastToImmutableList(
Objects.requireNonNull(qualifier, "qualifier can not be
null"));
this.nullable = nullable;
- this.table = table;
- this.column = column;
+ this.originalTable = originalTable;
+ this.originalColumn = originalColumn;
+ this.oneLevelTable = oneLevelTable;
+ this.oneLevelColumn = oneLevelColumn;
this.subPath = Objects.requireNonNull(subPath, "subPath can not be
null");
- this.internalName = internalName;
}
public static SlotReference of(String name, DataType type) {
@@ -132,16 +131,13 @@ public class SlotReference extends Slot {
* @param qualifier the qualifier of SlotReference
*/
public static SlotReference fromColumn(TableIf table, Column column,
List<String> qualifier) {
- DataType dataType = DataType.fromCatalogType(column.getType());
- return new SlotReference(StatementScopeIdGenerator.newExprId(),
column::getName, dataType,
- column.isAllowNull(), qualifier, table, column,
- () -> Optional.of(column.getName()), ImmutableList.of(),
Optional.empty());
+ return fromColumn(table, column, column.getName(), qualifier);
}
public static SlotReference fromColumn(TableIf table, Column column,
String name, List<String> qualifier) {
DataType dataType = DataType.fromCatalogType(column.getType());
return new SlotReference(StatementScopeIdGenerator.newExprId(), name,
dataType,
- column.isAllowNull(), qualifier, table, column, Optional.empty(),
ImmutableList.of());
+ column.isAllowNull(), qualifier, table, column, table, column,
ImmutableList.of());
}
@Override
@@ -169,17 +165,20 @@ public class SlotReference extends Slot {
return nullable;
}
- @Override
- public String getInternalName() {
- return internalName.get().get();
+ public Optional<TableIf> getOriginalTable() {
+ return Optional.ofNullable(originalTable);
}
- public Optional<Column> getColumn() {
- return Optional.ofNullable(column);
+ public Optional<Column> getOriginalColumn() {
+ return Optional.ofNullable(originalColumn);
}
- public Optional<TableIf> getTable() {
- return Optional.ofNullable(table);
+ public Optional<TableIf> getOneLevelTable() {
+ return Optional.ofNullable(oneLevelTable);
+ }
+
+ public Optional<Column> getOneLevelColumn() {
+ return Optional.ofNullable(oneLevelColumn);
}
@Override
@@ -258,8 +257,9 @@ public class SlotReference extends Slot {
if (this.nullable == nullable) {
return this;
}
- return new SlotReference(exprId, name, dataType, nullable,
- qualifier, table, column, internalName, subPath,
indexInSqlString);
+ return new SlotReference(exprId, name, dataType, nullable, qualifier,
+ originalTable, originalColumn, oneLevelTable, oneLevelColumn,
+ subPath, indexInSqlString);
}
@Override
@@ -267,14 +267,16 @@ public class SlotReference extends Slot {
if (this.nullable == nullable && this.dataType.equals(dataType)) {
return this;
}
- return new SlotReference(exprId, name, dataType, nullable,
- qualifier, table, column, internalName, subPath,
indexInSqlString);
+ return new SlotReference(exprId, name, dataType, nullable, qualifier,
+ originalTable, originalColumn, oneLevelTable, oneLevelColumn,
+ subPath, indexInSqlString);
}
@Override
public SlotReference withQualifier(List<String> qualifier) {
- return new SlotReference(exprId, name, dataType, nullable, qualifier,
table, column, internalName, subPath,
- indexInSqlString);
+ return new SlotReference(exprId, name, dataType, nullable, qualifier,
+ originalTable, originalColumn, oneLevelTable, oneLevelColumn,
+ subPath, indexInSqlString);
}
@Override
@@ -282,35 +284,46 @@ public class SlotReference extends Slot {
if (this.name.get().equals(name)) {
return this;
}
- return new SlotReference(
- exprId, () -> name, dataType, nullable, qualifier, table,
column, internalName, subPath,
- indexInSqlString);
+ return new SlotReference(exprId, () -> name, dataType, nullable,
qualifier,
+ originalTable, originalColumn, oneLevelTable, oneLevelColumn,
+ subPath, indexInSqlString);
}
@Override
public SlotReference withExprId(ExprId exprId) {
- return new SlotReference(exprId, name, dataType, nullable, qualifier,
table, column, internalName, subPath,
- indexInSqlString);
+ return new SlotReference(exprId, name, dataType, nullable, qualifier,
+ originalTable, originalColumn, oneLevelTable, oneLevelColumn,
+ subPath, indexInSqlString);
}
public SlotReference withSubPath(List<String> subPath) {
- return new SlotReference(exprId, name, dataType, !subPath.isEmpty() ||
nullable,
- qualifier, table, column, internalName, subPath,
indexInSqlString);
+ return new SlotReference(exprId, name, dataType, !subPath.isEmpty() ||
nullable, qualifier,
+ originalTable, originalColumn, oneLevelTable, oneLevelColumn,
+ subPath, indexInSqlString);
}
@Override
public Slot withIndexInSql(Pair<Integer, Integer> index) {
- return new SlotReference(exprId, name, dataType, nullable, qualifier,
table, column, internalName, subPath,
- Optional.ofNullable(index));
+ return new SlotReference(exprId, name, dataType, nullable, qualifier,
+ originalTable, originalColumn, oneLevelTable, oneLevelColumn,
+ subPath, Optional.ofNullable(index));
}
public SlotReference withColumn(Column column) {
- return new SlotReference(exprId, name, dataType, nullable, qualifier,
table, column, internalName, subPath,
- indexInSqlString);
+ return new SlotReference(exprId, name, dataType, nullable, qualifier,
+ originalTable, column, oneLevelTable, column,
+ subPath, indexInSqlString);
+ }
+
+ @Override
+ public Slot withOneLevelTableAndColumnAndQualifier(TableIf oneLevelTable,
Column column, List<String> qualifier) {
+ return new SlotReference(exprId, name, dataType, nullable, qualifier,
+ originalTable, column, oneLevelTable, column,
+ subPath, indexInSqlString);
}
public boolean isVisible() {
- return column == null || column.isVisible();
+ return originalColumn == null || originalColumn.isVisible();
}
public List<String> getSubPath() {
@@ -321,24 +334,11 @@ public class SlotReference extends Slot {
return !subPath.isEmpty();
}
- private static Supplier<Optional<String>> buildInternalName(
- Supplier<String> name, List<String> subColLabels, Optional<String>
internalName) {
- if (subColLabels != null && !subColLabels.isEmpty()) {
- // Modify internal name to distinguish from different sub-columns
of same top level column,
- // using the `.` to connect each part of paths
- return Suppliers.memoize(() ->
- Optional.of(internalName.orElse(name.get()) +
String.join(".", subColLabels)));
- } else {
- return Suppliers.memoize(() ->
- internalName.isPresent() ? internalName :
Optional.of(name.get()));
- }
- }
-
public String getQualifiedNameWithBackquote() throws UnboundException {
return Utils.qualifiedNameWithBackquote(getQualifier(), getName());
}
public boolean hasAutoInc() {
- return column != null ? column.isAutoInc() : false;
+ return originalColumn != null ? originalColumn.isAutoInc() : false;
}
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/AnyValue.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/AnyValue.java
index e9726ff9ff2..785e073bfaa 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/AnyValue.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/AnyValue.java
@@ -51,7 +51,7 @@ public class AnyValue extends NullableAggregateFunction
* constructor with 1 argument.
*/
public AnyValue(boolean distinct, Expression arg) {
- this(distinct, false, arg);
+ this(false, false, arg);
}
private AnyValue(boolean distinct, boolean alwaysNullable, Expression arg)
{
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/AddConstraintCommand.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/AddConstraintCommand.java
index f92a3b6103b..b7b34ed6185 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/AddConstraintCommand.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/AddConstraintCommand.java
@@ -100,9 +100,9 @@ public class AddConstraintCommand extends Command
implements ForwardWithSync {
ImmutableList<String> columns = analyzedPlan.getOutput().stream()
.map(s -> {
Preconditions.checkArgument(s instanceof SlotReference
- && ((SlotReference)
s).getColumn().isPresent(),
+ && ((SlotReference)
s).getOriginalColumn().isPresent(),
"Constraint contains a invalid slot ", s);
- return ((SlotReference) s).getColumn().get().getName();
+ return ((SlotReference)
s).getOriginalColumn().get().getName();
}).collect(ImmutableList.toImmutableList());
return Pair.of(columns, catalogRelation.getTable());
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateMaterializedViewCommand.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateMaterializedViewCommand.java
index 2f5d858f75b..92cf266f584 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateMaterializedViewCommand.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateMaterializedViewCommand.java
@@ -289,7 +289,7 @@ public class CreateMaterializedViewCommand extends Command
implements ForwardWit
Set<Slot> slots = expr.getInputSlots();
for (Slot slot : slots) {
if (slot instanceof SlotReference) {
- Column column = ((SlotReference)
slot).getColumn().orElse(null);
+ Column column = ((SlotReference)
slot).getOriginalColumn().orElse(null);
if (column != null) {
if (column.isVisible()) {
AggregateType aggregateType =
column.getAggregationType();
@@ -729,7 +729,7 @@ public class CreateMaterializedViewCommand extends Command
implements ForwardWit
private AggregateType getAggTypeFromSlot(Slot slot) {
if (slot instanceof SlotReference) {
- Column column = ((SlotReference)
slot).getColumn().orElse(null);
+ Column column = ((SlotReference)
slot).getOriginalColumn().orElse(null);
if (column != null && column.isVisible()) {
return column.getAggregationType();
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateTableCommand.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateTableCommand.java
index f76d272aded..16a384edaac 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateTableCommand.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateTableCommand.java
@@ -124,8 +124,8 @@ public class CreateTableCommand extends Command implements
NeedAuditEncryption,
dataType = TypeCoercionUtils.replaceSpecifiedType(dataType,
DecimalV2Type.class, DecimalV2Type.SYSTEM_DEFAULT);
if (s.isColumnFromTable()) {
- if ((!((SlotReference) s).getTable().isPresent()
- || !((SlotReference)
s).getTable().get().isManagedTable())) {
+ if ((!((SlotReference) s).getOriginalTable().isPresent()
+ || !((SlotReference)
s).getOriginalTable().get().isManagedTable())) {
if
(createTableInfo.getPartitionTableInfo().inIdentifierPartitions(s.getName())
|| (createTableInfo.getDistribution() != null
&&
createTableInfo.getDistribution().inDistributionColumns(s.getName()))) {
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DeleteFromCommand.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DeleteFromCommand.java
index 896f7520683..146e03189a3 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DeleteFromCommand.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DeleteFromCommand.java
@@ -297,10 +297,10 @@ public class DeleteFromCommand extends Command implements
ForwardWithSync, Expla
private void checkColumn(Set<String> tableColumns, SlotReference
slotReference, OlapTable table) {
// 0. must slot from table
- if (!slotReference.getColumn().isPresent()) {
+ if (!slotReference.getOriginalColumn().isPresent()) {
throw new AnalysisException("");
}
- Column column = slotReference.getColumn().get();
+ Column column = slotReference.getOriginalColumn().get();
if (Column.DELETE_SIGN.equalsIgnoreCase(column.getName())) {
return;
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AlterViewInfo.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AlterViewInfo.java
index 483c37a8388..e1446dde9bd 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AlterViewInfo.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AlterViewInfo.java
@@ -44,10 +44,10 @@ public class AlterViewInfo extends BaseViewInfo {
private final String comment;
/** constructor*/
- public AlterViewInfo(TableNameInfo viewName,
+ public AlterViewInfo(TableNameInfo viewName, String comment,
String querySql, List<SimpleColumnDefinition>
simpleColumnDefinitions) {
super(viewName, querySql, simpleColumnDefinitions);
- this.comment = null;
+ this.comment = comment;
}
public AlterViewInfo(TableNameInfo viewName, String comment) {
@@ -78,7 +78,7 @@ public class AlterViewInfo extends BaseViewInfo {
ErrorReport.reportAnalysisException(ErrorCode.ERR_TABLE_ACCESS_DENIED_ERROR,
PrivPredicate.ALTER.getPrivs().toString(),
viewName.getTbl());
}
- if (comment != null) {
+ if (querySql == null) {
// Modify comment only.
return;
}
@@ -91,7 +91,7 @@ public class AlterViewInfo extends BaseViewInfo {
/**translateToLegacyStmt*/
public AlterViewStmt translateToLegacyStmt(ConnectContext ctx) {
- if (comment != null) {
+ if (querySql == null) {
return new AlterViewStmt(viewName.transferToTableName(), comment);
}
// expand star(*) in project list and replace table name with qualifier
@@ -103,7 +103,7 @@ public class AlterViewInfo extends BaseViewInfo {
for (SimpleColumnDefinition def : simpleColumnDefinitions) {
cols.add(def.translateToColWithComment());
}
- AlterViewStmt alterViewStmt = new
AlterViewStmt(viewName.transferToTableName(), cols, null);
+ AlterViewStmt alterViewStmt = new
AlterViewStmt(viewName.transferToTableName(), cols, null, comment);
alterViewStmt.setInlineViewDef(rewrittenSql);
alterViewStmt.setFinalColumns(finalCols);
return alterViewStmt;
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateViewInfo.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateViewInfo.java
index d3cd4293f41..d0605753ae9 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateViewInfo.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateViewInfo.java
@@ -31,6 +31,7 @@ import org.apache.doris.nereids.trees.expressions.Slot;
import org.apache.doris.nereids.util.PlanUtils;
import org.apache.doris.qe.ConnectContext;
+import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import java.util.List;
@@ -49,7 +50,7 @@ public class CreateViewInfo extends BaseViewInfo {
super(viewName, querySql, simpleColumnDefinitions);
this.ifNotExists = ifNotExists;
this.orReplace = orReplace;
- this.comment = comment;
+ this.comment = Strings.nullToEmpty(comment);
}
/** init */
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalCTEConsumer.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalCTEConsumer.java
index 415fdddf80b..2941392ea71 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalCTEConsumer.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalCTEConsumer.java
@@ -108,9 +108,10 @@ public class LogicalCTEConsumer extends LogicalRelation
implements BlockFuncDeps
return new SlotReference(StatementScopeIdGenerator.newExprId(),
producerOutputSlot.getName(), producerOutputSlot.getDataType(),
producerOutputSlot.nullable(), ImmutableList.of(cteName),
- slotRef != null ? (slotRef.getTable().isPresent() ?
slotRef.getTable().get() : null) : null,
- slotRef != null ? (slotRef.getColumn().isPresent() ?
slotRef.getColumn().get() : null) : null,
- slotRef != null ? Optional.of(slotRef.getInternalName()) :
Optional.empty());
+ slotRef != null ? slotRef.getOriginalTable().orElse(null) :
null,
+ slotRef != null ? slotRef.getOriginalColumn().orElse(null) :
null,
+ slotRef != null ? slotRef.getOneLevelTable().orElse(null) :
null,
+ slotRef != null ? slotRef.getOneLevelColumn().orElse(null) :
null);
}
public Map<Slot, Slot> getConsumerToProducerOutputMap() {
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalCatalogRelation.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalCatalogRelation.java
index d6e90804830..f9c7438c20c 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalCatalogRelation.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalCatalogRelation.java
@@ -188,7 +188,7 @@ public abstract class LogicalCatalogRelation extends
LogicalRelation implements
continue;
}
SlotReference slotRef = (SlotReference) slot;
- if (slotRef.getColumn().isPresent() &&
columns.contains(slotRef.getColumn().get())) {
+ if (slotRef.getOriginalColumn().isPresent() &&
columns.contains(slotRef.getOriginalColumn().get())) {
slotSet.add(slotRef);
}
}
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 3d095287c44..d28ba05220f 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
@@ -608,7 +608,7 @@ public class LogicalOlapScan extends LogicalCatalogRelation
implements OlapScan
continue;
}
SlotReference slotRef = (SlotReference) slot;
- if (slotRef.getColumn().isPresent() &&
slotRef.getColumn().get().isKey()) {
+ if (slotRef.getOriginalColumn().isPresent() &&
slotRef.getOriginalColumn().get().isKey()) {
uniqSlots.add(slot);
}
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalView.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalView.java
index 0eaec7c3c18..c9be2ae5b52 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalView.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalView.java
@@ -31,6 +31,7 @@ import
org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
import org.apache.doris.nereids.util.Utils;
import com.google.common.collect.ImmutableList;
+import org.apache.commons.collections.CollectionUtils;
import java.util.List;
import java.util.Objects;
@@ -81,13 +82,13 @@ public class LogicalView<BODY extends Plan> extends
LogicalUnary<BODY> {
@Override
public Plan withGroupExpression(Optional<GroupExpression> groupExpression)
{
- return new LogicalView(view, child());
+ return new LogicalView<>(view, child());
}
@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression>
groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan>
children) {
- return new LogicalView(view, child());
+ return new LogicalView<>(view, child());
}
@Override
@@ -123,8 +124,15 @@ public class LogicalView<BODY extends Plan> extends
LogicalUnary<BODY> {
List<String> fullQualifiers = this.view.getFullQualifiers();
for (int i = 0; i < childOutput.size(); i++) {
Slot originSlot = childOutput.get(i);
- Slot qualified = originSlot
- .withQualifier(fullQualifiers);
+ Slot qualified;
+ // ATTN: because bug intro by #40715, after replace view, full
schema will be empty or null.
+ // So, we must just here to avoid NPE or out of bound exception.
+ if (CollectionUtils.isEmpty(view.getFullSchema())) {
+ qualified = originSlot.withQualifier(fullQualifiers);
+ } else {
+ qualified = originSlot
+ .withOneLevelTableAndColumnAndQualifier(view,
view.getFullSchema().get(i), fullQualifiers);
+ }
currentOutput.add(qualified);
}
return currentOutput.build();
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalCatalogRelation.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalCatalogRelation.java
index 4a4b6b61ffd..34970b25a0c 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalCatalogRelation.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalCatalogRelation.java
@@ -181,7 +181,7 @@ public abstract class PhysicalCatalogRelation extends
PhysicalRelation implement
continue;
}
SlotReference slotRef = (SlotReference) slot;
- if (slotRef.getColumn().isPresent() &&
columns.contains(slotRef.getColumn().get())) {
+ if (slotRef.getOriginalColumn().isPresent() &&
columns.contains(slotRef.getOriginalColumn().get())) {
slotSet.add(slotRef);
}
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/util/PlanUtils.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/util/PlanUtils.java
index fd04250c0fe..fe3a7db085a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/util/PlanUtils.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/util/PlanUtils.java
@@ -286,8 +286,8 @@ public class PlanUtils {
*/
public static boolean isColumnRef(Expression expr) {
return expr instanceof SlotReference
- && ((SlotReference) expr).getColumn().isPresent()
- && ((SlotReference) expr).getTable().isPresent();
+ && ((SlotReference) expr).getOriginalColumn().isPresent()
+ && ((SlotReference) expr).getOriginalTable().isPresent();
}
/**
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/qe/PointQueryExecutor.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/PointQueryExecutor.java
index 6010c7e0b17..5925b428a16 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/PointQueryExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/PointQueryExecutor.java
@@ -146,7 +146,7 @@ public class PointQueryExecutor implements CoordInterface {
// update conjuncts
Map<String, Expr> colNameToConjunct = Maps.newHashMap();
for (Entry<PlaceholderId, SlotReference> entry :
statementContext.getIdToComparisonSlot().entrySet()) {
- String colName = entry.getValue().getColumn().get().getName();
+ String colName =
entry.getValue().getOriginalColumn().get().getName();
Expr conjunctVal = ((Literal)
statementContext.getIdToPlaceholderRealExpr()
.get(entry.getKey())).toLegacyLiteral();
colNameToConjunct.put(colName, conjunctVal);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
index ebc892f038d..0f62f695aa0 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
@@ -2884,11 +2884,11 @@ public class StmtExecutor {
for (Slot slot : output) {
serializer.reset();
if (slot instanceof SlotReference
- && ((SlotReference) slot).getColumn().isPresent()
- && ((SlotReference) slot).getTable().isPresent()) {
+ && ((SlotReference)
slot).getOriginalColumn().isPresent()
+ && ((SlotReference)
slot).getOriginalTable().isPresent()) {
SlotReference slotReference = (SlotReference) slot;
- TableIf table = slotReference.getTable().get();
- Column column = slotReference.getColumn().get();
+ TableIf table = slotReference.getOriginalTable().get();
+ Column column = slotReference.getOriginalColumn().get();
DatabaseIf database = table.getDatabase();
String dbName = database == null ? "" :
database.getFullName();
serializer.writeField(dbName, table.getName(), column,
false);
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/statistics/AnalysisManager.java
b/fe/fe-core/src/main/java/org/apache/doris/statistics/AnalysisManager.java
index 8b34ac4de18..b0a91736761 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/statistics/AnalysisManager.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/statistics/AnalysisManager.java
@@ -1749,8 +1749,8 @@ public class AnalysisManager implements Writable {
if (!(s instanceof SlotReference)) {
return;
}
- Optional<Column> optionalColumn = ((SlotReference) s).getColumn();
- Optional<TableIf> optionalTable = ((SlotReference) s).getTable();
+ Optional<Column> optionalColumn = ((SlotReference)
s).getOriginalColumn();
+ Optional<TableIf> optionalTable = ((SlotReference)
s).getOriginalTable();
if (optionalColumn.isPresent() && optionalTable.isPresent()
&&
!StatisticsUtil.isUnsupportedType(optionalColumn.get().getType())) {
TableIf table = optionalTable.get();
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/statistics/Statistics.java
b/fe/fe-core/src/main/java/org/apache/doris/statistics/Statistics.java
index 99537a51a2e..ed74babc43c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/statistics/Statistics.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/statistics/Statistics.java
@@ -200,7 +200,7 @@ public class Statistics {
boolean allUnknown = true;
for (Slot slot : slots) {
if (slot instanceof SlotReference) {
- Optional<Column> colOpt = ((SlotReference) slot).getColumn();
+ Optional<Column> colOpt = ((SlotReference)
slot).getOriginalColumn();
if (colOpt.isPresent() && colOpt.get().isVisible()) {
ColumnStatistic colStats =
expressionToColumnStats.get(slot);
if (colStats != null && !colStats.isUnKnown) {
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/statistics/hbo/ScanPlanStatistics.java
b/fe/fe-core/src/main/java/org/apache/doris/statistics/hbo/ScanPlanStatistics.java
index 117dd838bd8..31835dded5a 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/statistics/hbo/ScanPlanStatistics.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/statistics/hbo/ScanPlanStatistics.java
@@ -75,8 +75,8 @@ public class ScanPlanStatistics extends PlanStatistics {
for (Expression expr : tableFilterSet) {
Set<Slot> inputSlot = expr.getInputSlots();
if (inputSlot.size() == 1 && inputSlot.iterator().next()
instanceof SlotReference
- && ((SlotReference)
inputSlot.iterator().next()).getColumn().isPresent()) {
- Column filterColumn = ((SlotReference)
inputSlot.iterator().next()).getColumn().get();
+ && ((SlotReference)
inputSlot.iterator().next()).getOriginalColumn().isPresent()) {
+ Column filterColumn = ((SlotReference)
inputSlot.iterator().next()).getOriginalColumn().get();
if
(partitionInfo.getPartitionColumns().contains(filterColumn)) {
partitionColumnPredicates.add(expr);
} else {
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/mtmv/MTMVPlanUtilTest.java
b/fe/fe-core/src/test/java/org/apache/doris/mtmv/MTMVPlanUtilTest.java
index 110f457cd00..25e73b37506 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/mtmv/MTMVPlanUtilTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/mtmv/MTMVPlanUtilTest.java
@@ -144,7 +144,7 @@ public class MTMVPlanUtilTest extends SqlTestBase {
minTimes = 0;
result = true;
- slot.getTable();
+ slot.getOriginalTable();
minTimes = 0;
result = Optional.empty();
@@ -171,7 +171,7 @@ public class MTMVPlanUtilTest extends SqlTestBase {
// test managed table
new Expectations() {
{
- slot.getTable();
+ slot.getOriginalTable();
minTimes = 0;
result = Optional.of(slotTable);
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 d26417247eb..181ab5ba08c 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
@@ -81,8 +81,9 @@ public class DeriveStatsJobTest {
long tableId1 = 0;
OlapTable table1 = PlanConstructor.newOlapTable(tableId1, "t1", 0);
List<String> qualifier = ImmutableList.of("test", "t");
- slot1 = new SlotReference(new ExprId(1), "c1", IntegerType.INSTANCE,
true, qualifier, table1,
- new Column("e", PrimitiveType.INT));
+ slot1 = new SlotReference(new ExprId(1), "c1", IntegerType.INSTANCE,
true, qualifier,
+ table1, new Column("e", PrimitiveType.INT),
+ table1, new Column("e", PrimitiveType.INT));
new Expectations() {{
ConnectContext.get();
result = context;
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/AnalyzeWhereSubqueryTest.java
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/AnalyzeWhereSubqueryTest.java
index e551a1e0bf6..28993a66c5c 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/AnalyzeWhereSubqueryTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/AnalyzeWhereSubqueryTest.java
@@ -169,7 +169,7 @@ public class AnalyzeWhereSubqueryTest extends
TestWithFeService implements MemoP
"test",
"t7")))).withAlwaysNullable(
true),
- "sum(k3)"))))
+ "sum(t7.k3)"))))
)
).when(FieldChecker.check("correlationSlot",
ImmutableList.of(
new SlotReference(new ExprId(1), "k2",
BigIntType.INSTANCE, true,
@@ -195,7 +195,7 @@ public class AnalyzeWhereSubqueryTest extends
TestWithFeService implements MemoP
new Alias(new ExprId(7), (new
Sum(
new SlotReference(new
ExprId(4), "k3", BigIntType.INSTANCE, true,
ImmutableList.of("test", "t7")))).withAlwaysNullable(true),
- "sum(k3)"),
+ "sum(t7.k3)"),
new SlotReference(new
ExprId(6), "v2", BigIntType.INSTANCE, true,
ImmutableList.of("test", "t7"))
)))
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/ExpressionRewriteTestHelper.java
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/ExpressionRewriteTestHelper.java
index 1bf2d1432a9..3763c6145d8 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/ExpressionRewriteTestHelper.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/ExpressionRewriteTestHelper.java
@@ -113,7 +113,7 @@ public abstract class ExpressionRewriteTestHelper extends
ExpressionRewrite {
List<String> qualifier = ImmutableList.of();
DataType dataType = getType(name.charAt(0));
Column column = new Column(name, dataType.toCatalogDataType());
- mem.putIfAbsent(name, new SlotReference(exprId, name, dataType,
true, qualifier, null, column));
+ mem.putIfAbsent(name, new SlotReference(exprId, name, dataType,
true, qualifier, null, column, null, null));
return mem.get(name);
}
return hasNewChildren ? expression.withChildren(children) : expression;
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/EliminateGroupByTest.java
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/EliminateGroupByTest.java
index 70eb8e4a470..f2a9e480f32 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/EliminateGroupByTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/EliminateGroupByTest.java
@@ -93,7 +93,7 @@ class EliminateGroupByTest extends TestWithFeService
implements MemoPatternMatch
.matches(
logicalEmptyRelation().when(p ->
p.getProjects().get(0).toSql().equals("id")
&& p.getProjects().get(1).toSql()
- .equals("if(age IS NULL, 0, 1) AS `if(age IS
NULL, 0, 1)`")
+ .equals("if(age IS NULL, 0, 1) AS
`count(age)`")
&&
p.getProjects().get(1).getDataType().isBigIntType()
)
);
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 cf91eacb51c..75cf3f2bea0 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
@@ -246,8 +246,9 @@ public class StatsCalculatorTest {
long tableId1 = 0;
OlapTable table1 = PlanConstructor.newOlapTable(tableId1, "t1", 0);
List<String> qualifier = ImmutableList.of("test", "t");
- SlotReference slot1 = new SlotReference(new ExprId(0),
- "c1", IntegerType.INSTANCE, true, qualifier, table1, new
Column("c1", PrimitiveType.INT));
+ SlotReference slot1 = new SlotReference(new ExprId(0), "c1",
IntegerType.INSTANCE, true, qualifier,
+ table1, new Column("c1", PrimitiveType.INT),
+ table1, new Column("c1", PrimitiveType.INT));
LogicalOlapScan logicalOlapScan1 = (LogicalOlapScan) new
LogicalOlapScan(
StatementScopeIdGenerator.newRelationId(), table1,
@@ -265,8 +266,9 @@ public class StatsCalculatorTest {
@Test
public void testLimit() {
List<String> qualifier = ImmutableList.of("test", "t");
- SlotReference slot1 = new SlotReference(new ExprId(0),
- "c1", IntegerType.INSTANCE, true, qualifier, null, new
Column("c1", PrimitiveType.INT));
+ SlotReference slot1 = new SlotReference(new ExprId(0), "c1",
IntegerType.INSTANCE, true, qualifier,
+ null, new Column("c1", PrimitiveType.INT),
+ null, new Column("c1", PrimitiveType.INT));
ColumnStatisticBuilder columnStat1 = new ColumnStatisticBuilder();
columnStat1.setNdv(10);
columnStat1.setNumNulls(5);
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/ConstraintTest.java
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/ConstraintTest.java
index ea9d3ab30d6..c0ea7643697 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/ConstraintTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/ConstraintTest.java
@@ -134,8 +134,8 @@ class ConstraintTest extends TestWithFeService implements
PlanPatternMatchSuppor
Constraint c = o.getTable().getConstraint("fk");
if (c instanceof ForeignKeyConstraint) {
ForeignKeyConstraint f = (ForeignKeyConstraint) c;
- Column ref1 = f.getReferencedColumn(((SlotReference)
o.getOutput().get(0)).getColumn().get().getName());
- Column ref2 = f.getReferencedColumn(((SlotReference)
o.getOutput().get(1)).getColumn().get().getName());
+ Column ref1 = f.getReferencedColumn(((SlotReference)
o.getOutput().get(0)).getOriginalColumn().get().getName());
+ Column ref2 = f.getReferencedColumn(((SlotReference)
o.getOutput().get(1)).getOriginalColumn().get().getName());
return ref1.getName().equals("k1") &&
ref2.getName().equals("k2");
}
return false;
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/qe/OlapQueryCacheTest.java
b/fe/fe-core/src/test/java/org/apache/doris/qe/OlapQueryCacheTest.java
index e8b545f3ffe..77db87b9231 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/qe/OlapQueryCacheTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/qe/OlapQueryCacheTest.java
@@ -451,6 +451,10 @@ public class OlapQueryCacheTest {
Analyzer createViewAnalyzer = new Analyzer(env, ctx);
createViewAnalyzer.setRootStatementClazz(CreateViewStmt.class);
view.setInlineViewDefWithSqlMode(parseSql(originStmt,
createViewAnalyzer, true).toSql(), 0L);
+ view.setNewFullSchema(Lists.newArrayList(
+ new Column("eventdate", ScalarType.DATE),
+ new Column("_count_2", ScalarType.BIGINT)
+ ));
return view;
}
@@ -460,6 +464,10 @@ public class OlapQueryCacheTest {
Analyzer createViewAnalyzer = new Analyzer(env, ctx);
createViewAnalyzer.setRootStatementClazz(CreateViewStmt.class);
view.setInlineViewDefWithSqlMode(parseSql(originStmt,
createViewAnalyzer, true).toSql(), 0L);
+ view.setNewFullSchema(Lists.newArrayList(
+ new Column("eventdate", ScalarType.DATE),
+ new Column("userid", ScalarType.INT)
+ ));
return view;
}
@@ -470,6 +478,10 @@ public class OlapQueryCacheTest {
Analyzer createViewAnalyzer = new Analyzer(env, ctx);
createViewAnalyzer.setRootStatementClazz(CreateViewStmt.class);
view.setInlineViewDefWithSqlMode(parseSql(originStmt,
createViewAnalyzer, true).toSql(), 0L);
+ view.setNewFullSchema(Lists.newArrayList(
+ new Column("eventdate", ScalarType.DATE),
+ new Column("_count_2", ScalarType.BIGINT)
+ ));
return view;
}
@@ -481,6 +493,10 @@ public class OlapQueryCacheTest {
createViewAnalyzer.setRootStatementClazz(CreateViewStmt.class);
view.setInlineViewDefWithSqlMode(
parseSql(originStmt, createViewAnalyzer, true).toSql(), 0L);
+ view.setNewFullSchema(Lists.newArrayList(
+ new Column("eventdate", ScalarType.DATE),
+ new Column("_count_2", ScalarType.BIGINT)
+ ));
return view;
}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/statistics/AnalysisManagerTest.java
b/fe/fe-core/src/test/java/org/apache/doris/statistics/AnalysisManagerTest.java
index 6bcbec50047..c79a0404863 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/statistics/AnalysisManagerTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/statistics/AnalysisManagerTest.java
@@ -61,7 +61,6 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Optional;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
@@ -381,11 +380,11 @@ public class AnalysisManagerTest {
};
SlotReference slot1 = new SlotReference(new ExprId(1), "slot1",
IntegerType.INSTANCE, true,
- new ArrayList<>(), table, column1, Optional.empty(),
ImmutableList.of());
+ new ArrayList<>(), table, column1, table, column1,
ImmutableList.of());
SlotReference slot2 = new SlotReference(new ExprId(2), "slot2",
IntegerType.INSTANCE, true,
- new ArrayList<>(), table, column2, Optional.empty(),
ImmutableList.of());
+ new ArrayList<>(), table, column2, table, column2,
ImmutableList.of());
SlotReference slot3 = new SlotReference(new ExprId(3), "slot3",
IntegerType.INSTANCE, true,
- new ArrayList<>(), table, column3, Optional.empty(),
ImmutableList.of());
+ new ArrayList<>(), table, column3, table, column3,
ImmutableList.of());
Set<Slot> set1 = new HashSet<>();
set1.add(slot1);
set1.add(slot2);
diff --git a/regression-test/data/ddl_p0/test_create_or_replace_view.out
b/regression-test/data/ddl_p0/test_create_or_replace_view.out
index 30c254b2386..cf385f2e9f7 100644
Binary files a/regression-test/data/ddl_p0/test_create_or_replace_view.out and
b/regression-test/data/ddl_p0/test_create_or_replace_view.out differ
diff --git
a/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query24.out
b/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query24.out
index ace0813e2e7..9e39054cba9 100644
Binary files
a/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query24.out and
b/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query24.out differ
diff --git
a/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query6.out
b/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query6.out
index fe17bd5d3c7..3a5d6b4d440 100644
Binary files
a/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query6.out and
b/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query6.out differ
diff --git
a/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query24.out
b/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query24.out
index 5815f02327d..45565a464e5 100644
Binary files
a/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query24.out and
b/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query24.out differ
diff --git
a/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query6.out
b/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query6.out
index 81aba1038a5..538ad1a80e2 100644
Binary files
a/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query6.out and
b/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query6.out differ
diff --git a/regression-test/data/shape_check/tpcds_sf100/rf_prune/query24.out
b/regression-test/data/shape_check/tpcds_sf100/rf_prune/query24.out
index 2c6c329803d..1a8f5d556b5 100644
Binary files
a/regression-test/data/shape_check/tpcds_sf100/rf_prune/query24.out and
b/regression-test/data/shape_check/tpcds_sf100/rf_prune/query24.out differ
diff --git a/regression-test/data/shape_check/tpcds_sf100/rf_prune/query6.out
b/regression-test/data/shape_check/tpcds_sf100/rf_prune/query6.out
index ddb58c3887e..e398b7817e6 100644
Binary files a/regression-test/data/shape_check/tpcds_sf100/rf_prune/query6.out
and b/regression-test/data/shape_check/tpcds_sf100/rf_prune/query6.out differ
diff --git a/regression-test/data/shape_check/tpcds_sf100/shape/query24.out
b/regression-test/data/shape_check/tpcds_sf100/shape/query24.out
index 14dbf92e98e..04fcb9fdf6b 100644
Binary files a/regression-test/data/shape_check/tpcds_sf100/shape/query24.out
and b/regression-test/data/shape_check/tpcds_sf100/shape/query24.out differ
diff --git a/regression-test/data/shape_check/tpcds_sf100/shape/query6.out
b/regression-test/data/shape_check/tpcds_sf100/shape/query6.out
index 43c8732d7f8..c6a9eb72ff0 100644
Binary files a/regression-test/data/shape_check/tpcds_sf100/shape/query6.out
and b/regression-test/data/shape_check/tpcds_sf100/shape/query6.out differ
diff --git
a/regression-test/data/shape_check/tpcds_sf1000/bs_downgrade_shape/query6.out
b/regression-test/data/shape_check/tpcds_sf1000/bs_downgrade_shape/query6.out
index 43c8732d7f8..c6a9eb72ff0 100644
Binary files
a/regression-test/data/shape_check/tpcds_sf1000/bs_downgrade_shape/query6.out
and
b/regression-test/data/shape_check/tpcds_sf1000/bs_downgrade_shape/query6.out
differ
diff --git a/regression-test/data/shape_check/tpcds_sf1000/hint/query24.out
b/regression-test/data/shape_check/tpcds_sf1000/hint/query24.out
index a928ebd4ab3..4e8d72d0ebb 100644
Binary files a/regression-test/data/shape_check/tpcds_sf1000/hint/query24.out
and b/regression-test/data/shape_check/tpcds_sf1000/hint/query24.out differ
diff --git a/regression-test/data/shape_check/tpcds_sf1000/hint/query6.out
b/regression-test/data/shape_check/tpcds_sf1000/hint/query6.out
index 43c8732d7f8..c6a9eb72ff0 100644
Binary files a/regression-test/data/shape_check/tpcds_sf1000/hint/query6.out
and b/regression-test/data/shape_check/tpcds_sf1000/hint/query6.out differ
diff --git a/regression-test/data/shape_check/tpcds_sf1000/shape/query24.out
b/regression-test/data/shape_check/tpcds_sf1000/shape/query24.out
index b1e5bf29828..9311f413058 100644
Binary files a/regression-test/data/shape_check/tpcds_sf1000/shape/query24.out
and b/regression-test/data/shape_check/tpcds_sf1000/shape/query24.out differ
diff --git a/regression-test/data/shape_check/tpcds_sf1000/shape/query6.out
b/regression-test/data/shape_check/tpcds_sf1000/shape/query6.out
index 43c8732d7f8..c6a9eb72ff0 100644
Binary files a/regression-test/data/shape_check/tpcds_sf1000/shape/query6.out
and b/regression-test/data/shape_check/tpcds_sf1000/shape/query6.out differ
diff --git a/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query24.out
b/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query24.out
index 09f12e931c6..060bac4d1e0 100644
Binary files
a/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query24.out and
b/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query24.out differ
diff --git a/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query6.out
b/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query6.out
index 0c390df2e8e..8ac3c948319 100644
Binary files
a/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query6.out and
b/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query6.out differ
diff --git a/regression-test/data/shape_check/tpch_sf1000/hint/q11.out
b/regression-test/data/shape_check/tpch_sf1000/hint/q11.out
index c37989eb189..d726e84b919 100644
Binary files a/regression-test/data/shape_check/tpch_sf1000/hint/q11.out and
b/regression-test/data/shape_check/tpch_sf1000/hint/q11.out differ
diff --git
a/regression-test/data/shape_check/tpch_sf1000/nostats_rf_prune/q11.out
b/regression-test/data/shape_check/tpch_sf1000/nostats_rf_prune/q11.out
index 6d414f1f56a..dcb4189583a 100644
Binary files
a/regression-test/data/shape_check/tpch_sf1000/nostats_rf_prune/q11.out and
b/regression-test/data/shape_check/tpch_sf1000/nostats_rf_prune/q11.out differ
diff --git
a/regression-test/data/shape_check/tpch_sf1000/nostats_rf_prune/q22.out
b/regression-test/data/shape_check/tpch_sf1000/nostats_rf_prune/q22.out
index 176b64caf78..5f75b319bf0 100644
Binary files
a/regression-test/data/shape_check/tpch_sf1000/nostats_rf_prune/q22.out and
b/regression-test/data/shape_check/tpch_sf1000/nostats_rf_prune/q22.out differ
diff --git a/regression-test/data/shape_check/tpch_sf1000/rf_prune/q11.out
b/regression-test/data/shape_check/tpch_sf1000/rf_prune/q11.out
index 40df7553b03..48fbc3d1a1f 100644
Binary files a/regression-test/data/shape_check/tpch_sf1000/rf_prune/q11.out
and b/regression-test/data/shape_check/tpch_sf1000/rf_prune/q11.out differ
diff --git a/regression-test/data/shape_check/tpch_sf1000/rf_prune/q22.out
b/regression-test/data/shape_check/tpch_sf1000/rf_prune/q22.out
index 207538326c7..69a80f708f9 100644
Binary files a/regression-test/data/shape_check/tpch_sf1000/rf_prune/q22.out
and b/regression-test/data/shape_check/tpch_sf1000/rf_prune/q22.out differ
diff --git a/regression-test/data/shape_check/tpch_sf1000/shape/q11.out
b/regression-test/data/shape_check/tpch_sf1000/shape/q11.out
index 40df7553b03..48fbc3d1a1f 100644
Binary files a/regression-test/data/shape_check/tpch_sf1000/shape/q11.out and
b/regression-test/data/shape_check/tpch_sf1000/shape/q11.out differ
diff --git a/regression-test/data/shape_check/tpch_sf1000/shape/q22.out
b/regression-test/data/shape_check/tpch_sf1000/shape/q22.out
index 207538326c7..69a80f708f9 100644
Binary files a/regression-test/data/shape_check/tpch_sf1000/shape/q22.out and
b/regression-test/data/shape_check/tpch_sf1000/shape/q22.out differ
diff --git
a/regression-test/data/shape_check/tpch_sf1000/shape_no_stats/q11.out
b/regression-test/data/shape_check/tpch_sf1000/shape_no_stats/q11.out
index 6d414f1f56a..dcb4189583a 100644
Binary files
a/regression-test/data/shape_check/tpch_sf1000/shape_no_stats/q11.out and
b/regression-test/data/shape_check/tpch_sf1000/shape_no_stats/q11.out differ
diff --git
a/regression-test/data/shape_check/tpch_sf1000/shape_no_stats/q22.out
b/regression-test/data/shape_check/tpch_sf1000/shape_no_stats/q22.out
index 176b64caf78..5f75b319bf0 100644
Binary files
a/regression-test/data/shape_check/tpch_sf1000/shape_no_stats/q22.out and
b/regression-test/data/shape_check/tpch_sf1000/shape_no_stats/q22.out differ
diff --git a/regression-test/suites/ddl_p0/test_create_or_replace_view.groovy
b/regression-test/suites/ddl_p0/test_create_or_replace_view.groovy
index 8617d5d0ae1..301be38542d 100644
--- a/regression-test/suites/ddl_p0/test_create_or_replace_view.groovy
+++ b/regression-test/suites/ddl_p0/test_create_or_replace_view.groovy
@@ -60,6 +60,11 @@ suite("test_create_or_replace_view") {
CREATE OR REPLACE VIEW view_test_create_or_replace_view
AS SELECT * FROM test_create_or_replace_view_tbl2;
"""
+
+ qt_desc_view_upper_after_replace """
+ desc view_test_create_or_replace_view
+ """
+
qt_sql_2 """select * from view_test_create_or_replace_view"""
qt_desc_view_upper_after_replace """
diff --git a/regression-test/suites/mysql_compatibility_p0/metadata.groovy
b/regression-test/suites/mysql_compatibility_p0/metadata.groovy
index 5b441383e7e..f6b303dbfd6 100644
--- a/regression-test/suites/mysql_compatibility_p0/metadata.groovy
+++ b/regression-test/suites/mysql_compatibility_p0/metadata.groovy
@@ -23,6 +23,10 @@ suite ("metadata") {
drop table if exists metadata
"""
+ sql """
+ drop view if exists view_metadata
+ """
+
sql """
create table metadata (
k1 int null,
@@ -33,28 +37,57 @@ suite ("metadata") {
properties("replication_num" = "1");
"""
- sql """insert into metadata values (1, 1, 1)"""
+ def (tableResult, tableMeta) =
JdbcUtils.executeToList(context.getConnection(), "select k1 + 1 as c1, k2 c2,
abs(k3) as c3 from metadata ta ")
- sql """sync"""
+ println tableMeta
- def (result, meta) = JdbcUtils.executeToList(context.getConnection(),
"select k1 + 1 as c1, k2 c2, abs(k3) as c3 from metadata ta ")
+ assertEquals("c1", tableMeta.getColumnName(1))
+ assertEquals("k2", tableMeta.getColumnName(2))
+ assertEquals("c3", tableMeta.getColumnName(3))
- println meta
+ assertEquals("c1", tableMeta.getColumnLabel(1))
+ assertEquals("c2", tableMeta.getColumnLabel(2))
+ assertEquals("c3", tableMeta.getColumnLabel(3))
- assertEquals("c1", meta.getColumnName(1))
- assertEquals("k2", meta.getColumnName(2))
- assertEquals("c3", meta.getColumnName(3))
+ assertEquals("", tableMeta.getTableName(1))
+ assertEquals("metadata", tableMeta.getTableName(2))
+ assertEquals("", tableMeta.getTableName(3))
+
+ sql """
+ create view view_metadata as
+ select k1 as vk1, k2 from metadata
+ """
- assertEquals("c1", meta.getColumnLabel(1))
- assertEquals("c2", meta.getColumnLabel(2))
- assertEquals("c3", meta.getColumnLabel(3))
+ def (viewResult, viewMeta) =
JdbcUtils.executeToList(context.getConnection(), "select vk1 + 1 as c1, vk1 c2,
vk1, k2 c3, k2, abs(k2) as c4 from view_metadata ta")
- assertEquals("", meta.getTableName(1))
- assertEquals("metadata", meta.getTableName(2))
- assertEquals("", meta.getTableName(3))
+ println viewMeta
+ assertEquals("c1", viewMeta.getColumnName(1))
+ assertEquals("vk1", viewMeta.getColumnName(2))
+ assertEquals("vk1", viewMeta.getColumnName(3))
+ assertEquals("k2", viewMeta.getColumnName(4))
+ assertEquals("k2", viewMeta.getColumnName(5))
+ assertEquals("c4", viewMeta.getColumnName(6))
+
+ assertEquals("c1", viewMeta.getColumnLabel(1))
+ assertEquals("c2", viewMeta.getColumnLabel(2))
+ assertEquals("vk1", viewMeta.getColumnLabel(3))
+ assertEquals("c3", viewMeta.getColumnLabel(4))
+ assertEquals("k2", viewMeta.getColumnLabel(5))
+ assertEquals("c4", viewMeta.getColumnLabel(6))
+
+ assertEquals("", viewMeta.getTableName(1))
+ assertEquals("view_metadata", viewMeta.getTableName(2))
+ assertEquals("view_metadata", viewMeta.getTableName(3))
+ assertEquals("view_metadata", viewMeta.getTableName(4))
+ assertEquals("view_metadata", viewMeta.getTableName(5))
+ assertEquals("", viewMeta.getTableName(6))
sql """
drop table if exists metadata
"""
+
+ sql """
+ drop view if exists view_metadata
+ """
}
diff --git
a/regression-test/suites/nereids_p0/cte/test_cte_with_duplicate_consumer.groovy
b/regression-test/suites/nereids_p0/cte/test_cte_with_duplicate_consumer.groovy
index b5cb03ea174..893376456f6 100644
---
a/regression-test/suites/nereids_p0/cte/test_cte_with_duplicate_consumer.groovy
+++
b/regression-test/suites/nereids_p0/cte/test_cte_with_duplicate_consumer.groovy
@@ -14,15 +14,13 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-import org.junit.Assert;
suite("test_cte_with_duplicate_consumer") {
- try {
+ test {
sql """
WITH cte1(col1) AS (SELECT 1), cte2(col2_1, col2_2) AS (SELECT
col1, col1 FROM cte1) SELECT * FROM cte2
"""
- } catch (Exception e) {
- // Duplicated inline view column alias: 'col1' in inline view: 'cte2''
- assertTrue(e.message.contains(" Duplicated inline view column alias"))
+
+ result([[1, 1]])
}
test {
diff --git
a/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_by_fe.groovy
b/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_by_fe.groovy
index ab0353dab6a..5f054a47188 100644
---
a/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_by_fe.groovy
+++
b/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_by_fe.groovy
@@ -206,10 +206,10 @@ suite("test_fold_constant_by_fe") {
// test null like string cause of fe need to fold constant like that to
enable not null derive
res = sql """explain select null like '%123%'"""
- assertFalse(res.contains("like"))
+ assertTrue(res.contains("NULL"))
// now fe fold constant still can not deal with this case
res = sql """explain select "12" like '%123%'"""
- assertTrue(res.contains("like"))
+ assertFalse(res.contains("NULL"))
testFoldConst("select DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY) + INTERVAL
3600 SECOND")
diff --git
a/regression-test/suites/nereids_p0/subquery/test_duplicate_name_in_view.groovy
b/regression-test/suites/nereids_p0/subquery/test_duplicate_name_in_view.groovy
deleted file mode 100644
index 775636aba17..00000000000
---
a/regression-test/suites/nereids_p0/subquery/test_duplicate_name_in_view.groovy
+++ /dev/null
@@ -1,175 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-suite("test_duplicate_name_in_view") {
- sql "SET enable_nereids_planner=true"
- sql "SET enable_fallback_to_original_planner=false"
- sql """
- drop table if exists issue_19611_t0;
- """
-
- sql """
- drop table if exists issue_19611_t1;
- """
-
- sql """
- create table issue_19611_t0 (c0 int)
- ENGINE=OLAP
- DISTRIBUTED BY HASH(c0) BUCKETS 5
- PROPERTIES (
- "replication_allocation" = "tag.location.default: 1",
- "in_memory" = "false",
- "storage_format" = "V2"
- );
- """
-
- sql """
- create table issue_19611_t1 (c0 int)
- ENGINE=OLAP
- DISTRIBUTED BY HASH(c0) BUCKETS 5
- PROPERTIES (
- "replication_allocation" = "tag.location.default: 1",
- "in_memory" = "false",
- "storage_format" = "V2"
- );
- """
-
- test {
- sql """
- select * from (
- select * from issue_19611_t0, issue_19611_t1 where
issue_19611_t1.c0 != 0
- union select * from issue_19611_t0, issue_19611_t1 where
issue_19611_t1.c0 = 0) tmp;
- """
- exception "Duplicated inline view column alias: 'c0' in inline view:
'tmp'"
-
- }
-
- test {
- sql """
- SELECT *
- FROM
- (SELECT issue_19611_t1.c0 ,
- issue_19611_t1.c0
- FROM issue_19611_t1 ) tmp;
- """
- exception "Duplicated inline view column alias: 'c0' in inline view:
'tmp'"
- }
-
- test {
- sql """
- SELECT *
- FROM
- (SELECT issue_19611_t1.c0 + 1,
- issue_19611_t1.c0 + 1
- FROM issue_19611_t1 ) tmp;
- """
- exception "Duplicated inline view column alias: 'issue_19611_t1.c0 +
1' in inline view: 'tmp'"
- }
-
- test {
- sql """
- SELECT *
- FROM
- (SELECT issue_19611_t1.c0 ,
- issue_19611_t0.c0
- FROM issue_19611_t1, issue_19611_t0 ) tmp;
- """
- exception "Duplicated inline view column alias: 'c0' in inline view:
'tmp'"
- }
-
- test {
- sql """
- SELECT *
- FROM
- (SELECT issue_19611_t1.c0 a,
- issue_19611_t1.c0 a
- FROM issue_19611_t1 ) tmp;
- """
- exception "Duplicated inline view column alias: 'a' in inline view:
'tmp'"
- }
-
- test {
- sql """
- SELECT *
- FROM
- (SELECT issue_19611_t0.c0 + 1 a,
- issue_19611_t1.c0 + 1 a
- FROM issue_19611_t1, issue_19611_t0 ) tmp;
- """
- exception "Duplicated inline view column alias: 'a' in inline view:
'tmp'"
- }
-
- test {
- sql """
- SELECT *
- FROM
- (SELECT '2023-10-07', '2023-10-07'
- FROM issue_19611_t1 ) tmp;
- """
- exception "Duplicated inline view column alias: ''2023-10-07'' in
inline view: 'tmp'"
- }
-
- test {
- sql """
- SELECT *
- FROM
- (SELECT '2023-10-07' a, '2023-10-07' a
- FROM issue_19611_t1 ) tmp;
- """
- exception "Duplicated inline view column alias: 'a' in inline view:
'tmp'"
- }
-
- sql """SELECT *
- FROM
- (SELECT issue_19611_t1.c0 + 1,
- issue_19611_t0.c0 + 1
- FROM issue_19611_t1, issue_19611_t0 ) tmp;
- """
-
- sql """SELECT *
- FROM
- (SELECT issue_19611_t1.c0 a,
- issue_19611_t1.c0 b
- FROM issue_19611_t1 ) tmp;"""
-
- sql """SELECT *
- FROM
- (SELECT issue_19611_t1.c0 a,
- issue_19611_t1.c0
- FROM issue_19611_t1 ) tmp;"""
-
- sql """SELECT *
- FROM
- (SELECT '2023-10-07' a, '2023-10-07' b
- FROM issue_19611_t1 ) tmp;
- """
-
- sql """SELECT *
- FROM
- (SELECT '2023-10-07' a, '2023-10-07'
- FROM issue_19611_t1 ) tmp;
- """
-
-
- sql """
- drop table if exists issue_19611_t0;
- """
-
- sql """
- drop table if exists issue_19611_t1;
- """
-}
diff --git
a/regression-test/suites/nereids_rules_p0/expression/test_convert_median_to_percentile.groovy
b/regression-test/suites/nereids_rules_p0/expression/test_convert_median_to_percentile.groovy
index dd5b8032df6..2d8cf3a8b59 100644
---
a/regression-test/suites/nereids_rules_p0/expression/test_convert_median_to_percentile.groovy
+++
b/regression-test/suites/nereids_rules_p0/expression/test_convert_median_to_percentile.groovy
@@ -62,14 +62,14 @@ suite("test_convert_median_to_percentile") {
def sql3 = "select year, median(profit) from sales group by year order by
year"
def sql4 = "select year, percentile(profit, 0.5) from sales group by year
order by year"
def explainStr3 = sql """ explain ${sql3} """
- assertTrue(explainStr3.toString().contains("percentile(profit, 0.5)"))
+ assertTrue(explainStr3.toString().contains("percentile(profit"))
qt_select_3 "${sql3}"
qt_select_4 "${sql4}"
def sql5 = "select year, median(profit) from sales group by year having
median(profit) > 100"
def sql6 = "select year, percentile(profit, 0.5) from sales group by year
having percentile(profit, 0.5) > 100"
def explainStr5 = sql """ explain ${sql5} """
- assertTrue(explainStr5.toString().contains("percentile(profit, 0.5)"))
+ assertTrue(explainStr5.toString().contains("percentile(profit"))
qt_select_5 "${sql5}"
qt_select_6 "${sql6}"
diff --git a/regression-test/suites/nereids_syntax_p0/explain.groovy
b/regression-test/suites/nereids_syntax_p0/explain.groovy
index 5b1bfa1f8ae..ca3a06fa303 100644
--- a/regression-test/suites/nereids_syntax_p0/explain.groovy
+++ b/regression-test/suites/nereids_syntax_p0/explain.groovy
@@ -69,8 +69,7 @@ suite("explain") {
assertTrue(!explainStr.contains("projections"))
explain {
- sql("select week(cast('0000-01-01' as DATEV2), cast(2 as INT));")
- notContains "week"
- contains "1"
+ sql("select week(cast('0000-02-02' as DATEV2), cast(2 as INT));")
+ contains "5"
}
}
diff --git a/regression-test/suites/query_p0/cte/query_with_dup_column.groovy
b/regression-test/suites/query_p0/cte/query_with_dup_column.groovy
deleted file mode 100644
index be88cb44bab..00000000000
--- a/regression-test/suites/query_p0/cte/query_with_dup_column.groovy
+++ /dev/null
@@ -1,112 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-import org.junit.Assert;
-
-suite("query_with_dup_column") {
- String db = context.config.getDbNameByFile(context.file)
- sql "use ${db}"
- sql "set runtime_filter_mode=OFF";
- sql "SET ignore_shape_nodes='PhysicalDistribute,PhysicalProject'"
-
- sql """
- drop table if exists test_table;
- """
-
- sql """
- CREATE TABLE `test_table` (
- `unique_id` varchar(256) NULL,
- `name` varchar(256) NULL
- )
- PROPERTIES (
- "replication_num" = "1"
- );
- """
-
- sql """
- insert into test_table values ("yyyxxxzzz", "abc000000")
- """
-
- // should fail
- try {
- sql """
- with tmp1 as (
- select unique_id, unique_id from test_table
- )
- select * from tmp1;
- """
- } catch (Exception e) {
- assertTrue(e.message.contains("Duplicated inline view column alias"))
- }
-
- // should fail
- try {
- sql """
- with tmp1 as (
- select unique_id, unique_id from test_table
- )
- select * from tmp1 t;
- """
- } catch (Exception e) {
- assertTrue(e.message.contains("Duplicated inline view column alias"))
- }
-
-
- try {
- sql """
- with tmp1 as (
- select *, unique_id from test_table
- )
- select * from tmp1;
- """
- } catch (Exception e) {
- assertTrue(e.message.contains("Duplicated inline view column alias"))
- }
-
- // should fail
- try {
- sql """
- with tmp1 as (
- select *, unique_id from test_table
- )
- select * from tmp1 t;
- """
- } catch (Exception e) {
- assertTrue(e.message.contains("Duplicated inline view column alias"))
- }
-
- // should success
- sql """
- select *, unique_id from test_table;
- """
-
- // should success
- sql """
- select *, unique_id from test_table t;
- """
-
- // should success
- sql """
- select unique_id, unique_id from test_table
- """
-
- // should success
- sql """
- select unique_id, unique_id from test_table t
- """
-}
-
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]