diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/LogicalProperties.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/LogicalProperties.java index eec6318fcf1735..07d2882894288c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/LogicalProperties.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/LogicalProperties.java @@ -43,17 +43,11 @@ public class LogicalProperties { protected final Supplier> outputMapSupplier; protected final Supplier> outputExprIdSetSupplier; protected final Supplier fdSupplier; - protected final Supplier> outputExpressionSupplier; private Integer hashCode = null; - public LogicalProperties(Supplier> outputSupplier, - Supplier fdSupplier, Supplier> outputExpressionSupplier) { - this(outputSupplier, fdSupplier, outputExpressionSupplier, ImmutableList::of); - } - public LogicalProperties(Supplier> outputSupplier, Supplier fdSupplier) { - this(outputSupplier, fdSupplier, null, ImmutableList::of); + this(outputSupplier, fdSupplier, ImmutableList::of); } /** @@ -64,7 +58,6 @@ public LogicalProperties(Supplier> outputSupplier, */ public LogicalProperties(Supplier> outputSupplier, Supplier fdSupplier, - Supplier> outputExpressionSupplier, Supplier> nonUserVisibleOutputSupplier) { this.outputSupplier = Suppliers.memoize( Objects.requireNonNull(outputSupplier, "outputSupplier can not be null") @@ -87,8 +80,6 @@ public LogicalProperties(Supplier> outputSupplier, this.fdSupplier = Suppliers.memoize( Objects.requireNonNull(fdSupplier, "FunctionalDependencies can not be null") ); - this.outputExpressionSupplier = Suppliers.memoize(Objects.requireNonNull(outputExpressionSupplier, - "outputExpressionSupplier can not be null")); } public List getOutput() { @@ -115,10 +106,6 @@ public List getOutputExprIds() { return outputExprIdsSupplier.get(); } - public List getOutputExpression() { - return outputExpressionSupplier.get(); - } - @Override public String toString() { return "LogicalProperties{" diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/AbstractPlan.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/AbstractPlan.java index 780f536bdb69ce..4be6d35dc94692 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/AbstractPlan.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/AbstractPlan.java @@ -24,7 +24,6 @@ import org.apache.doris.nereids.properties.UnboundLogicalProperties; import org.apache.doris.nereids.trees.AbstractTreeNode; import org.apache.doris.nereids.trees.expressions.ExprId; -import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.expressions.StatementScopeIdGenerator; import org.apache.doris.nereids.trees.plans.logical.LogicalPlan; @@ -156,11 +155,6 @@ public Set getOutputExprIdSet() { return getLogicalProperties().getOutputExprIdSet(); } - @Override - public List getOutputExpression() { - return getLogicalProperties().getOutputExpression(); - } - @Override public LogicalProperties getLogicalProperties() { // TODO: use bound()? @@ -187,8 +181,7 @@ public LogicalProperties computeLogicalProperties() { Supplier fdSupplier = () -> this instanceof LogicalPlan ? ((LogicalPlan) this).computeFuncDeps(outputSupplier) : FunctionalDependencies.EMPTY_FUNC_DEPS; - Supplier> outputExpressionSupplier = Suppliers.memoize(this::computeOutputExpression); - return new LogicalProperties(outputSupplier, fdSupplier, outputExpressionSupplier); + return new LogicalProperties(outputSupplier, fdSupplier); } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/FakePlan.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/FakePlan.java index 7bc494c2b7a693..eedfbbd8aa2ad2 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/FakePlan.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/FakePlan.java @@ -21,7 +21,6 @@ import org.apache.doris.nereids.properties.FunctionalDependencies; import org.apache.doris.nereids.properties.LogicalProperties; import org.apache.doris.nereids.trees.expressions.Expression; -import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor; import org.apache.doris.nereids.util.MutableState; @@ -92,11 +91,6 @@ public List getOutput() { return new ArrayList<>(); } - @Override - public List getOutputExpression() { - return new ArrayList<>(); - } - @Override public String treeString() { return "DUMMY"; diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/Plan.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/Plan.java index 0d3fa194e032f7..1a35fecaf29417 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/Plan.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/Plan.java @@ -97,8 +97,6 @@ default boolean displayExtraPlanFirst() { */ List getOutput(); - List getOutputExpression(); - /** * Get output slot set of the plan. */ diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateViewCommand.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateViewCommand.java index 8a31c869348fda..d78308664b5e38 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateViewCommand.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateViewCommand.java @@ -36,6 +36,7 @@ public CreateViewCommand(CreateViewInfo createViewInfo) { @Override public void run(ConnectContext ctx, StmtExecutor executor) throws Exception { + createViewInfo.init(ctx); createViewInfo.validate(ctx); CreateViewStmt createViewStmt = createViewInfo.translateToLegacyStmt(ctx); Env.getCurrentEnv().createView(createViewStmt); 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 efdb0c97a8fe08..09a9e1ba71483d 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 @@ -48,9 +48,7 @@ import org.apache.doris.nereids.rules.analysis.BindRelationForCreateView; import org.apache.doris.nereids.rules.analysis.CheckPolicy; import org.apache.doris.nereids.rules.analysis.EliminateLogicalSelectHint; -import org.apache.doris.nereids.trees.expressions.Alias; import org.apache.doris.nereids.trees.expressions.BoundStar; -import org.apache.doris.nereids.trees.expressions.Expression; import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.plans.Plan; @@ -60,7 +58,6 @@ import org.apache.doris.nereids.trees.plans.logical.LogicalFileSink; import org.apache.doris.nereids.trees.plans.logical.LogicalPlan; import org.apache.doris.nereids.trees.plans.logical.LogicalProject; -import org.apache.doris.nereids.trees.plans.logical.LogicalSetOperation; import org.apache.doris.nereids.trees.plans.visitor.DefaultPlanVisitor; import org.apache.doris.nereids.util.Utils; import org.apache.doris.qe.ConnectContext; @@ -90,9 +87,8 @@ public class CreateViewInfo { private final List simpleColumnDefinitions; private final List finalCols = Lists.newArrayList(); private final List outputs = Lists.newArrayList(); - private final List projects = Lists.newArrayList(); private Plan analyzedPlan; - private Map, String> relationMap; + private Map, String> rewriteSqlMap; /** constructor*/ public CreateViewInfo(boolean ifNotExists, TableNameInfo viewName, String comment, LogicalPlan logicalQuery, @@ -108,6 +104,16 @@ public CreateViewInfo(boolean ifNotExists, TableNameInfo viewName, String commen this.simpleColumnDefinitions = simpleColumnDefinitions; } + /** init */ + public void init(ConnectContext ctx) throws UserException { + analyzeAndFillRewriteSqlMap(querySql, ctx); + OutermostPlanFinder outermostPlanFinder = new OutermostPlanFinder(); + AtomicReference outermostPlan = new AtomicReference<>(); + analyzedPlan.accept(outermostPlanFinder, outermostPlan); + outputs.addAll(outermostPlan.get().getOutput()); + createFinalCols(); + } + /**validate*/ public void validate(ConnectContext ctx) throws UserException { NereidsPlanner planner = new NereidsPlanner(ctx.getStatementContext()); @@ -121,14 +127,6 @@ public void validate(ConnectContext ctx) throws UserException { viewName.getTbl(), PrivPredicate.CREATE)) { ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR, "CREATE"); } - - analyzedPlan = parseAndAnalyzeView(querySql, ctx); - OutermostPlanFinder outermostPlanFinder = new OutermostPlanFinder(); - AtomicReference outermostPlan = new AtomicReference<>(); - analyzedPlan.accept(outermostPlanFinder, outermostPlan); - outputs.addAll(outermostPlan.get().getOutput()); - projects.addAll(outermostPlan.get().getOutputExpression()); - createFinalCols(); Set colSets = Sets.newTreeSet(String.CASE_INSENSITIVE_ORDER); for (Column col : finalCols) { if (!colSets.add(col.getName())) { @@ -145,23 +143,20 @@ public CreateViewStmt translateToLegacyStmt(ConnectContext ctx) { } CreateViewStmt createViewStmt = new CreateViewStmt(ifNotExists, viewName.transferToTableName(), cols, comment, null); - // expand star(*) in project list - Map, String> indexStringSqlMap = collectBoundStar(analyzedPlan); - indexStringSqlMap.putAll(relationMap); - String rewrittenSql = rewriteStarToColumn(indexStringSqlMap); + // expand star(*) in project list and replace table name with qualifier + String rewrittenSql = rewriteSql(rewriteSqlMap); // rewrite project alias - rewrittenSql = rewriteProjectsToUserDefineAlias2(rewrittenSql); + rewrittenSql = rewriteProjectsToUserDefineAlias(rewrittenSql); createViewStmt.setInlineViewDef(rewrittenSql); createViewStmt.setFinalColumns(finalCols); return createViewStmt; } - private Plan parseAndAnalyzeView(String ddlSql, ConnectContext ctx) { + private void analyzeAndFillRewriteSqlMap(String sql, ConnectContext ctx) { StatementContext stmtCtx = ctx.getStatementContext(); - LogicalPlan parsedViewPlan = new NereidsParser().parseSingle(ddlSql); - // TODO: use a good to do this, such as eliminate UnboundResultSink + LogicalPlan parsedViewPlan = new NereidsParser().parseSingle(sql); if (parsedViewPlan instanceof UnboundResultSink) { parsedViewPlan = (LogicalPlan) ((UnboundResultSink) parsedViewPlan).child(); } @@ -170,15 +165,16 @@ private Plan parseAndAnalyzeView(String ddlSql, ConnectContext ctx) { AnalyzerForCreateView analyzer = new AnalyzerForCreateView(viewContext, true); analyzer.analyze(); Plan planForRelation = viewContext.getRewritePlan(); - relationMap = collectUnBoundRelation(planForRelation); + rewriteSqlMap = collectUnBoundRelation(planForRelation); CascadesContext viewContextForStar = CascadesContext.initContext( stmtCtx, planForRelation, PhysicalProperties.ANY); AnalyzerForCreateView analyzerForStar = new AnalyzerForCreateView(viewContextForStar, false); analyzerForStar.analyze(); - return viewContextForStar.getRewritePlan(); + analyzedPlan = viewContextForStar.getRewritePlan(); + rewriteSqlMap.putAll(collectBoundStar(analyzedPlan)); } - private String rewriteStarToColumn(Map, String> indexStringSqlMap) { + private String rewriteSql(Map, String> indexStringSqlMap) { StringBuilder builder = new StringBuilder(); int beg = 0; for (Map.Entry, String> entry : indexStringSqlMap.entrySet()) { @@ -192,35 +188,6 @@ private String rewriteStarToColumn(Map, String> indexStri } private String rewriteProjectsToUserDefineAlias(String resSql) { - List projectExprs = Lists.newArrayList(); - for (int i = 0; i < projects.size(); i++) { - NamedExpression namedExpression = projects.get(i); - if (namedExpression instanceof Alias) { - projectExprs.add(namedExpression.child(0)); - } else { - projectExprs.add(namedExpression); - } - } - IndexFinder finder = new IndexFinder(); - ParserRuleContext tree = NereidsParser.toAst(resSql, DorisParser::singleStatement); - finder.visit(tree); - StringBuilder replaceWithColsBuilder = new StringBuilder(); - for (int i = 0; i < projectExprs.size(); ++i) { - replaceWithColsBuilder.append(projectExprs.get(i).toSql()); - replaceWithColsBuilder.append(" AS `"); - String escapeBacktick = finalCols.get(i).getName().replace("`", "``"); - replaceWithColsBuilder.append(escapeBacktick); - replaceWithColsBuilder.append('`'); - if (i != projectExprs.size() - 1) { - replaceWithColsBuilder.append(", "); - } - } - String replaceWithCols = replaceWithColsBuilder.toString(); - return StringUtils.overlay(resSql, replaceWithCols, finder.getIndex().first, - finder.getIndex().second + 1); - } - - private String rewriteProjectsToUserDefineAlias2(String resSql) { IndexFinder finder = new IndexFinder(); ParserRuleContext tree = NereidsParser.toAst(resSql, DorisParser::singleStatement); finder.visit(tree); @@ -324,14 +291,6 @@ public Void visitLogicalCTEProducer(LogicalCTEProducer cteProduc AtomicReference target) { return null; } - - @Override - public Void visitLogicalSetOperation(LogicalSetOperation setOperation, AtomicReference target) { - if (found) { - return null; - } - return super.visit(setOperation, target); - } } /** traverse ast to find the outermost project list location information in sql*/ @@ -368,7 +327,6 @@ public Void visitSelectColumnClause(DorisParser.SelectColumnClauseContext ctx) { stopIndex = ctx.getStop().getStopIndex(); found = true; - // 这里默认*已经被替换了,不存在*或者* except NamedExpressionSeqContext namedExpressionSeqContext = ctx.namedExpressionSeq(); namedExpressionContexts = namedExpressionSeqContext.namedExpression(); return null; diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalAggregate.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalAggregate.java index 900add75f89e1f..20647a3808ebe7 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalAggregate.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalAggregate.java @@ -390,9 +390,4 @@ public ImmutableSet computeFdItems(Supplier> outputSupplier) return builder.build(); } - - @Override - public List computeOutputExpression() { - return outputExpressions; - } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalApply.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalApply.java index 2472247f1d1c64..517048c209aba4 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalApply.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalApply.java @@ -23,7 +23,6 @@ import org.apache.doris.nereids.trees.expressions.Expression; import org.apache.doris.nereids.trees.expressions.InSubquery; import org.apache.doris.nereids.trees.expressions.MarkJoinSlotReference; -import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.ScalarSubquery; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.expressions.SubqueryExpr; @@ -162,17 +161,6 @@ public List computeOutput() { .build(); } - @Override - public List computeOutputExpression() { - return ImmutableList.builder() - .addAll(left().getOutputExpression()) - .addAll(markJoinSlotReference.isPresent() - ? ImmutableList.of(markJoinSlotReference.get()) : ImmutableList.of()) - .addAll(needAddSubOutputToProjects - ? ImmutableList.of(right().getOutputExpression().get(0)) : ImmutableList.of()) - .build(); - } - @Override public String toString() { return Utils.toSqlString("LogicalApply", diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalAssertNumRows.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalAssertNumRows.java index 6abcba3ebb26d9..0279c9701caaff 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalAssertNumRows.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalAssertNumRows.java @@ -21,7 +21,6 @@ import org.apache.doris.nereids.properties.LogicalProperties; import org.apache.doris.nereids.trees.expressions.AssertNumRowsElement; import org.apache.doris.nereids.trees.expressions.Expression; -import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.plans.Plan; import org.apache.doris.nereids.trees.plans.PlanType; @@ -119,10 +118,4 @@ public Plan withGroupExprLogicalPropChildren(Optional groupExpr public List computeOutput() { return child().getOutput().stream().map(o -> o.withNullable(true)).collect(Collectors.toList()); } - - @Override - public List computeOutputExpression() { - return child().getOutputExpression(); - } - } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalCTE.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalCTE.java index 8b6904ca8d69e6..7a75dd5c1a4abf 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalCTE.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalCTE.java @@ -20,7 +20,6 @@ import org.apache.doris.nereids.memo.GroupExpression; import org.apache.doris.nereids.properties.LogicalProperties; import org.apache.doris.nereids.trees.expressions.Expression; -import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.plans.Plan; import org.apache.doris.nereids.trees.plans.PlanType; @@ -71,11 +70,6 @@ public List computeOutput() { return child().getOutput(); } - @Override - public List computeOutputExpression() { - return child().getOutputExpression(); - } - @Override public String toString() { return Utils.toSqlString("LogicalCTE", diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalCTEAnchor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalCTEAnchor.java index 321dadaa174037..67aef52f979ead 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalCTEAnchor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalCTEAnchor.java @@ -21,7 +21,6 @@ import org.apache.doris.nereids.properties.LogicalProperties; import org.apache.doris.nereids.trees.expressions.CTEId; import org.apache.doris.nereids.trees.expressions.Expression; -import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.plans.Plan; import org.apache.doris.nereids.trees.plans.PlanType; @@ -84,11 +83,6 @@ public List computeOutput() { return right().getOutput(); } - @Override - public List computeOutputExpression() { - return right().getOutputExpression(); - } - public CTEId getCteId() { return cteId; } 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 2aa6bf4ee8555e..71b1c43f791191 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 @@ -20,7 +20,6 @@ import org.apache.doris.nereids.memo.GroupExpression; import org.apache.doris.nereids.properties.LogicalProperties; import org.apache.doris.nereids.trees.expressions.CTEId; -import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.expressions.SlotReference; import org.apache.doris.nereids.trees.expressions.StatementScopeIdGenerator; @@ -146,11 +145,6 @@ public List computeOutput() { return ImmutableList.copyOf(producerToConsumerOutputMap.values()); } - @Override - public List computeOutputExpression() { - return ImmutableList.copyOf(producerToConsumerOutputMap.values()); - } - public CTEId getCteId() { return cteId; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalCTEProducer.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalCTEProducer.java index 8fab3a1d427ae8..aeae13302d9245 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalCTEProducer.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalCTEProducer.java @@ -21,7 +21,6 @@ import org.apache.doris.nereids.properties.LogicalProperties; import org.apache.doris.nereids.trees.expressions.CTEId; import org.apache.doris.nereids.trees.expressions.Expression; -import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.plans.Plan; import org.apache.doris.nereids.trees.plans.PlanType; @@ -91,11 +90,6 @@ public List computeOutput() { return child().getOutput(); } - @Override - public List computeOutputExpression() { - return child().getOutputExpression(); - } - @Override public String toString() { return Utils.toSqlString("LogicalCteProducer[" + id.asInt() + "]", 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 380d9a30c4d711..4076e8348e2208 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 @@ -101,14 +101,6 @@ public List computeOutput() { .collect(ImmutableList.toImmutableList()); } - @Override - public List computeOutputExpression() { - return table.getBaseSchema() - .stream() - .map(col -> SlotReference.fromColumn(table, col, qualified(), this)) - .collect(ImmutableList.toImmutableList()); - } - public List getQualifier() { return qualifier; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalCheckPolicy.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalCheckPolicy.java index 800a2a3ccd3a49..bda3b1f49d570d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalCheckPolicy.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalCheckPolicy.java @@ -80,11 +80,6 @@ public List computeOutput() { return child().getOutput(); } - @Override - public List computeOutputExpression() { - return child().getOutputExpression(); - } - @Override public String toString() { return Utils.toSqlString("LogicalCheckPolicy"); diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalDeferMaterializeOlapScan.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalDeferMaterializeOlapScan.java index 23b98e76d7aad6..a49e37d8df40a0 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalDeferMaterializeOlapScan.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalDeferMaterializeOlapScan.java @@ -21,7 +21,6 @@ import org.apache.doris.nereids.memo.GroupExpression; import org.apache.doris.nereids.properties.LogicalProperties; import org.apache.doris.nereids.trees.expressions.ExprId; -import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.expressions.SlotReference; import org.apache.doris.nereids.trees.plans.Plan; @@ -111,14 +110,6 @@ public List computeOutput() { .build(); } - @Override - public List computeOutputExpression() { - return ImmutableList.builder() - .addAll(logicalOlapScan.getOutput()) - .add(columnIdSlot) - .build(); - } - @Override public Plan withGroupExpression(Optional groupExpression) { return new LogicalDeferMaterializeOlapScan(logicalOlapScan, deferMaterializeSlotIds, columnIdSlot, diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalDeferMaterializeTopN.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalDeferMaterializeTopN.java index 57b284aa1678ff..5bf0afe1faef59 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalDeferMaterializeTopN.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalDeferMaterializeTopN.java @@ -27,7 +27,6 @@ import org.apache.doris.nereids.properties.OrderKey; import org.apache.doris.nereids.trees.expressions.ExprId; import org.apache.doris.nereids.trees.expressions.Expression; -import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.expressions.SlotReference; import org.apache.doris.nereids.trees.plans.Plan; @@ -120,13 +119,6 @@ public List computeOutput() { .collect(ImmutableList.toImmutableList()); } - @Override - public List computeOutputExpression() { - return logicalTopN.getOutputExpression().stream() - .filter(s -> !(s.getExprId().equals(columnIdSlot.getExprId()))) - .collect(ImmutableList.toImmutableList()); - } - @Override public FunctionalDependencies computeFuncDeps(Supplier> outputSupplier) { FunctionalDependencies fd = child(0).getLogicalProperties().getFunctionalDependencies(); diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalEmptyRelation.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalEmptyRelation.java index 9555ccc2fab9dc..ab816f7a40859d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalEmptyRelation.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalEmptyRelation.java @@ -100,11 +100,6 @@ public List getOutputs() { return projects; } - @Override - public List getOutputExpression() { - return projects; - } - @Override public Plan pruneOutputs(List prunedOutputs) { return withProjects(prunedOutputs); diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalFilter.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalFilter.java index 907425d8e48c7d..4375124a22455d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalFilter.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalFilter.java @@ -23,7 +23,6 @@ import org.apache.doris.nereids.properties.FunctionalDependencies.Builder; import org.apache.doris.nereids.properties.LogicalProperties; import org.apache.doris.nereids.trees.expressions.Expression; -import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.expressions.SubqueryExpr; import org.apache.doris.nereids.trees.plans.Plan; @@ -88,11 +87,6 @@ public List computeOutput() { return child().getOutput(); } - @Override - public List computeOutputExpression() { - return child().getOutputExpression(); - } - @Override public String toString() { return Utils.toSqlString("LogicalFilter[" + id.asInt() + "]", diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalGenerate.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalGenerate.java index 2caa9e87d719f5..0fb3964e511f0a 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalGenerate.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalGenerate.java @@ -22,7 +22,6 @@ import org.apache.doris.nereids.properties.FunctionalDependencies; import org.apache.doris.nereids.properties.LogicalProperties; import org.apache.doris.nereids.trees.expressions.Expression; -import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.expressions.functions.Function; import org.apache.doris.nereids.trees.plans.Plan; @@ -131,14 +130,6 @@ public List computeOutput() { .build(); } - @Override - public List computeOutputExpression() { - return ImmutableList.builder() - .addAll(child().getOutput()) - .addAll(generatorOutput) - .build(); - } - @Override public String toString() { return Utils.toSqlString("LogicalGenerate", diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalHaving.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalHaving.java index dafa23406f2922..e4d01f127482b5 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalHaving.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalHaving.java @@ -23,7 +23,6 @@ import org.apache.doris.nereids.properties.FunctionalDependencies.Builder; import org.apache.doris.nereids.properties.LogicalProperties; import org.apache.doris.nereids.trees.expressions.Expression; -import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.plans.Plan; import org.apache.doris.nereids.trees.plans.PlanType; @@ -103,11 +102,6 @@ public List computeOutput() { return child().getOutput(); } - @Override - public List computeOutputExpression() { - return child().getOutputExpression(); - } - @Override public int hashCode() { return Objects.hashCode(conjuncts); diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalInlineTable.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalInlineTable.java index 009bbe89006871..b2a2a1d83ca3e7 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalInlineTable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalInlineTable.java @@ -82,11 +82,6 @@ public List computeOutput() { return ImmutableList.of(); } - @Override - public List computeOutputExpression() { - return ImmutableList.of(); - } - @Override public boolean equals(Object o) { if (this == o) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalJoin.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalJoin.java index 07282352cf8b47..d18a454fe73296 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalJoin.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalJoin.java @@ -34,7 +34,6 @@ import org.apache.doris.nereids.trees.expressions.ExprId; import org.apache.doris.nereids.trees.expressions.Expression; import org.apache.doris.nereids.trees.expressions.MarkJoinSlotReference; -import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.plans.DistributeType; import org.apache.doris.nereids.trees.plans.JoinType; @@ -265,15 +264,6 @@ public List computeOutput() { .build(); } - @Override - public List computeOutputExpression() { - return ImmutableList.builder() - .addAll(JoinUtils.getJoinOutput(joinType, left(), right())) - .addAll(isMarkJoin() - ? ImmutableList.of(markJoinSlotReference.get()) : ImmutableList.of()) - .build(); - } - @Override public String toString() { List args = Lists.newArrayList( diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalLimit.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalLimit.java index c56f7385ddf154..482c7e26058f25 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalLimit.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalLimit.java @@ -25,7 +25,6 @@ import org.apache.doris.nereids.properties.FunctionalDependencies.Builder; import org.apache.doris.nereids.properties.LogicalProperties; import org.apache.doris.nereids.trees.expressions.Expression; -import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.expressions.SlotReference; import org.apache.doris.nereids.trees.plans.LimitPhase; @@ -91,11 +90,6 @@ public List computeOutput() { return child().getOutput(); } - @Override - public List computeOutputExpression() { - return child().getOutputExpression(); - } - @Override public String toString() { return Utils.toSqlString("LogicalLimit", 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 f5d4e6e4a7e2c6..cb5d1847fef2a5 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 @@ -24,7 +24,6 @@ import org.apache.doris.nereids.properties.LogicalProperties; import org.apache.doris.nereids.rules.rewrite.mv.AbstractSelectMaterializedIndexRule; import org.apache.doris.nereids.trees.TableSample; -import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.expressions.SlotReference; import org.apache.doris.nereids.trees.plans.Plan; @@ -349,11 +348,6 @@ public List computeOutput() { return slots.build(); } - @Override - public List computeOutputExpression() { - return computeOutput().stream().map(slot -> (NamedExpression) slot).collect(Collectors.toList()); - } - @Override public Set getInputRelations() { Set relationIdSet = Sets.newHashSet(); diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOneRowRelation.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOneRowRelation.java index 0a77933f22ab74..d338be5cc88185 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOneRowRelation.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOneRowRelation.java @@ -94,11 +94,6 @@ public List computeOutput() { .collect(ImmutableList.toImmutableList()); } - @Override - public List computeOutputExpression() { - return projects; - } - @Override public boolean equals(Object o) { if (this == o) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalPartitionTopN.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalPartitionTopN.java index 9d246860b5d270..69da96e8f7ebcb 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalPartitionTopN.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalPartitionTopN.java @@ -20,7 +20,6 @@ import org.apache.doris.nereids.memo.GroupExpression; import org.apache.doris.nereids.properties.LogicalProperties; import org.apache.doris.nereids.trees.expressions.Expression; -import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.OrderExpression; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.expressions.WindowExpression; @@ -112,11 +111,6 @@ public List computeOutput() { return child().getOutput(); } - @Override - public List computeOutputExpression() { - return child().getOutputExpression(); - } - public WindowFuncType getFunction() { return function; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalProject.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalProject.java index 003121e5ed9645..4e19c5ca623efd 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalProject.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalProject.java @@ -275,9 +275,4 @@ public List getBoundStars() { public void setBoundStars(List boundStars) { this.boundStars = boundStars; } - - @Override - public List computeOutputExpression() { - return projects; - } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalRepeat.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalRepeat.java index ff738311182993..5e0311afe1b518 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalRepeat.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalRepeat.java @@ -108,11 +108,6 @@ public List computeOutput() { .collect(ImmutableList.toImmutableList()); } - @Override - public List computeOutputExpression() { - return outputExpressions; - } - @Override public R accept(PlanVisitor visitor, C context) { return visitor.visitLogicalRepeat(this, context); diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalSelectHint.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalSelectHint.java index e974a75b00ce0f..127889ea7ed471 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalSelectHint.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalSelectHint.java @@ -21,7 +21,6 @@ import org.apache.doris.nereids.properties.LogicalProperties; import org.apache.doris.nereids.properties.SelectHint; import org.apache.doris.nereids.trees.expressions.Expression; -import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.plans.BlockFuncDepsPropagation; import org.apache.doris.nereids.trees.plans.Plan; @@ -106,11 +105,6 @@ public List computeOutput() { return child().getOutput(); } - @Override - public List computeOutputExpression() { - return child().getOutputExpression(); - } - @Override public String toString() { String hintStr = this.hints.entrySet() diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalSetOperation.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalSetOperation.java index f8c3fa53305772..2e4ddb55ff2f02 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalSetOperation.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalSetOperation.java @@ -105,11 +105,6 @@ public List computeOutput() { .collect(ImmutableList.toImmutableList()); } - @Override - public List computeOutputExpression() { - return outputs; - } - public List> collectChildrenProjections() { return castCommonDataTypeOutputs(); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalSink.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalSink.java index 3da49ac7f99c2d..ea2fa49e4664bb 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalSink.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalSink.java @@ -66,11 +66,6 @@ public List computeOutput() { .collect(ImmutableList.toImmutableList()); } - @Override - public List computeOutputExpression() { - return outputExprs; - } - @Override public boolean equals(Object o) { if (this == o) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalSort.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalSort.java index 411372c20aac7c..9d9d321e659636 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalSort.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalSort.java @@ -21,7 +21,6 @@ import org.apache.doris.nereids.properties.LogicalProperties; import org.apache.doris.nereids.properties.OrderKey; import org.apache.doris.nereids.trees.expressions.Expression; -import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.plans.Plan; import org.apache.doris.nereids.trees.plans.PlanType; @@ -67,11 +66,6 @@ public List computeOutput() { return child().getOutput(); } - @Override - public List computeOutputExpression() { - return child().getOutputExpression(); - } - public List getOrderKeys() { return orderKeys; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalSubQueryAlias.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalSubQueryAlias.java index 16d41e30c09cdb..68a451f1df1b19 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalSubQueryAlias.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalSubQueryAlias.java @@ -22,7 +22,6 @@ import org.apache.doris.nereids.properties.FunctionalDependencies; import org.apache.doris.nereids.properties.LogicalProperties; import org.apache.doris.nereids.trees.expressions.Expression; -import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.plans.Plan; import org.apache.doris.nereids.trees.plans.PlanType; @@ -43,7 +42,6 @@ import java.util.Optional; import java.util.Set; import java.util.function.Supplier; -import java.util.stream.Collectors; /** * The node of logical plan for sub query and alias @@ -101,11 +99,6 @@ public List computeOutput() { return currentOutput.build(); } - @Override - public List computeOutputExpression() { - return computeOutput().stream().map(slot -> (NamedExpression) slot).collect(Collectors.toList()); - } - public String getAlias() { return qualifier.get(qualifier.size() - 1); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalTVFRelation.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalTVFRelation.java index 3a728e69534aa8..8302c9345dcc17 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalTVFRelation.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalTVFRelation.java @@ -19,7 +19,6 @@ import org.apache.doris.nereids.memo.GroupExpression; import org.apache.doris.nereids.properties.LogicalProperties; -import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.expressions.SlotReference; import org.apache.doris.nereids.trees.expressions.functions.table.TableValuedFunction; @@ -37,7 +36,6 @@ import java.util.List; import java.util.Objects; import java.util.Optional; -import java.util.stream.Collectors; /** LogicalTableValuedFunctionRelation */ public class LogicalTVFRelation extends LogicalRelation implements TVFRelation, BlockFuncDepsPropagation { @@ -105,11 +103,6 @@ public List computeOutput() { .collect(ImmutableList.toImmutableList()); } - @Override - public List computeOutputExpression() { - return computeOutput().stream().map(slot -> (NamedExpression) slot).collect(Collectors.toList()); - } - @Override public R accept(PlanVisitor visitor, C context) { return visitor.visitLogicalTVFRelation(this, context); diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalTopN.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalTopN.java index f57f7e077970d8..63e3dc9c0b9717 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalTopN.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalTopN.java @@ -26,7 +26,6 @@ import org.apache.doris.nereids.properties.LogicalProperties; import org.apache.doris.nereids.properties.OrderKey; import org.apache.doris.nereids.trees.expressions.Expression; -import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.expressions.SlotReference; import org.apache.doris.nereids.trees.plans.Plan; @@ -73,11 +72,6 @@ public List computeOutput() { return child().getOutput(); } - @Override - public List computeOutputExpression() { - return child().getOutputExpression(); - } - @Override public List getOrderKeys() { return orderKeys; 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 43485788b03bfe..e8621b1754c757 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 @@ -24,7 +24,6 @@ import org.apache.doris.nereids.properties.FunctionalDependencies; import org.apache.doris.nereids.properties.LogicalProperties; import org.apache.doris.nereids.trees.expressions.Expression; -import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.plans.Plan; import org.apache.doris.nereids.trees.plans.PlanType; @@ -129,11 +128,6 @@ public List computeOutput() { return child().getOutput(); } - @Override - public List computeOutputExpression() { - return child().getOutputExpression(); - } - @Override public FunctionalDependencies computeFuncDeps(Supplier> outputSupplier) { return ((LogicalPlan) child()).computeFuncDeps(outputSupplier); diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalWindow.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalWindow.java index ac9d2294d3308a..457678787bd738 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalWindow.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalWindow.java @@ -144,15 +144,6 @@ public List computeOutput() { .build(); } - @Override - public List computeOutputExpression() { - return new ImmutableList.Builder() - .addAll(child().getOutputExpression()) - .addAll(windowExpressions.stream() - .collect(ImmutableList.toImmutableList())) - .build(); - } - @Override public String toString() { return Utils.toSqlString("LogicalWindow", diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/util/JoinUtils.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/util/JoinUtils.java index 790855cb26efdd..a73c183e4e75c1 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/util/JoinUtils.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/util/JoinUtils.java @@ -30,7 +30,6 @@ import org.apache.doris.nereids.trees.expressions.ExprId; import org.apache.doris.nereids.trees.expressions.Expression; import org.apache.doris.nereids.trees.expressions.MarkJoinSlotReference; -import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.Not; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.expressions.functions.scalar.BitmapContains; @@ -389,24 +388,6 @@ public static List getJoinOutput(JoinType joinType, Plan left, Plan right) } } - /** getJoinOutputExpression */ - public static List getJoinOutputExpression(JoinType joinType, Plan left, Plan right) { - switch (joinType) { - case LEFT_SEMI_JOIN: - case LEFT_ANTI_JOIN: - case NULL_AWARE_LEFT_ANTI_JOIN: - return ImmutableList.copyOf(left.getOutputExpression()); - case RIGHT_SEMI_JOIN: - case RIGHT_ANTI_JOIN: - return ImmutableList.copyOf(right.getOutputExpression()); - default: - return ImmutableList.builder() - .addAll(left.getOutputExpression()) - .addAll(right.getOutputExpression()) - .build(); - } - } - public static boolean hasMarkConjuncts(Join join) { return !join.getMarkJoinConjuncts().isEmpty(); } diff --git a/regression-test/data/show_p0/test_show_create_table_and_views_nereids.out b/regression-test/data/show_p0/test_show_create_table_and_views_nereids.out deleted file mode 100644 index d88325d3711d83..00000000000000 --- a/regression-test/data/show_p0/test_show_create_table_and_views_nereids.out +++ /dev/null @@ -1,46 +0,0 @@ --- This file is automatically generated. You should know what you did if you want to edit this --- !show -- -show_create_table_and_views_table CREATE TABLE `show_create_table_and_views_table` (\n `user_id` LARGEINT NOT NULL,\n `good_id` LARGEINT NOT NULL,\n `cost` BIGINT SUM NULL DEFAULT "0"\n) ENGINE=OLAP\nAGGREGATE KEY(`user_id`, `good_id`)\nCOMMENT 'OLAP'\nPARTITION BY RANGE(`good_id`)\n(PARTITION p1 VALUES [("-170141183460469231731687303715884105728"), ("100")),\nPARTITION p2 VALUES [("100"), ("200")),\nPARTITION p3 VALUES [("200"), ("300")),\nPARTITION p4 VALUES [("300"), ("400")),\nPARTITION p5 VALUES [("400"), ("500")),\nPARTITION p6 VALUES [("500"), ("600")),\nPARTITION p7 VALUES [("600"), (MAXVALUE)))\nDISTRIBUTED BY HASH(`user_id`) BUCKETS 2\nPROPERTIES (\n"replication_allocation" = "tag.location.default: 1",\n"min_load_replica_num" = "-1",\n"is_being_synced" = "false",\n"storage_medium" = "hdd",\n"storage_format" = "V2",\n"inverted_index_storage_format" = "V1",\n"light_schema_change" = "true",\n"disable_auto_compaction" = "false",\n"enable_single_replica_compaction" = "false",\n"group_commit_interval_ms" = "10000",\n"group_commit_data_bytes" = "134217728"\n); - --- !select -- -1 1 30 -1 2 5 -1 3 10 -1 300 2 -2 1 100 -2 2 10 -2 3 44 -2 200 1111 -3 1 10 -3 2 1 -23 900 1 -100 100 1 -200 20 1 -300 20 1 - --- !select -- -1 5 -2 10 -3 1 - --- !show -- -show_create_table_and_views_view CREATE VIEW `show_create_table_and_views_view` COMMENT 'VIEW' AS SELECT user_id AS `user_id`, cost AS `cost` FROM `internal`.`show_create_table_and_views_db`.`show_create_table_and_views_table`\n WHERE good_id = 2; utf8mb4 utf8mb4_0900_bin - --- !select -- -1 47 -2 1265 -3 11 -23 1 -100 1 -200 1 -300 1 - --- !show -- -show_create_table_and_views_table CREATE TABLE `show_create_table_and_views_table` (\n `user_id` LARGEINT NOT NULL,\n `good_id` LARGEINT NOT NULL,\n `cost` BIGINT SUM NULL DEFAULT "0"\n) ENGINE=OLAP\nAGGREGATE KEY(`user_id`, `good_id`)\nCOMMENT 'OLAP'\nPARTITION BY RANGE(`good_id`)\n(PARTITION p1 VALUES [("-170141183460469231731687303715884105728"), ("100")),\nPARTITION p2 VALUES [("100"), ("200")),\nPARTITION p3 VALUES [("200"), ("300")),\nPARTITION p4 VALUES [("300"), ("400")),\nPARTITION p5 VALUES [("400"), ("500")),\nPARTITION p6 VALUES [("500"), ("600")),\nPARTITION p7 VALUES [("600"), (MAXVALUE)))\nDISTRIBUTED BY HASH(`user_id`) BUCKETS 2\nPROPERTIES (\n"replication_allocation" = "tag.location.default: 1",\n"min_load_replica_num" = "-1",\n"is_being_synced" = "false",\n"storage_medium" = "hdd",\n"storage_format" = "V2",\n"inverted_index_storage_format" = "V1",\n"light_schema_change" = "true",\n"disable_auto_compaction" = "false",\n"enable_single_replica_compaction" = "false",\n"group_commit_interval_ms" = "10000",\n"group_commit_data_bytes" = "134217728"\n); - --- !show -- -show_create_table_and_views_like CREATE TABLE `show_create_table_and_views_like` (\n `user_id` LARGEINT NOT NULL,\n `good_id` LARGEINT NOT NULL,\n `cost` BIGINT SUM NULL DEFAULT "0"\n) ENGINE=OLAP\nAGGREGATE KEY(`user_id`, `good_id`)\nCOMMENT 'OLAP'\nPARTITION BY RANGE(`good_id`)\n(PARTITION p1 VALUES [("-170141183460469231731687303715884105728"), ("100")),\nPARTITION p2 VALUES [("100"), ("200")),\nPARTITION p3 VALUES [("200"), ("300")),\nPARTITION p4 VALUES [("300"), ("400")),\nPARTITION p5 VALUES [("400"), ("500")),\nPARTITION p6 VALUES [("500"), ("600")),\nPARTITION p7 VALUES [("600"), (MAXVALUE)))\nDISTRIBUTED BY HASH(`user_id`) BUCKETS 2\nPROPERTIES (\n"replication_allocation" = "tag.location.default: 1",\n"min_load_replica_num" = "-1",\n"is_being_synced" = "false",\n"storage_medium" = "hdd",\n"storage_format" = "V2",\n"inverted_index_storage_format" = "V1",\n"light_schema_change" = "true",\n"disable_auto_compaction" = "false",\n"enable_single_replica_compaction" = "false",\n"group_commit_interval_ms" = "10000",\n"group_commit_data_bytes" = "134217728"\n); - --- !show -- -show_create_table_and_views_like_with_rollup CREATE TABLE `show_create_table_and_views_like_with_rollup` (\n `user_id` LARGEINT NOT NULL,\n `good_id` LARGEINT NOT NULL,\n `cost` BIGINT SUM NULL DEFAULT "0"\n) ENGINE=OLAP\nAGGREGATE KEY(`user_id`, `good_id`)\nCOMMENT 'OLAP'\nPARTITION BY RANGE(`good_id`)\n(PARTITION p1 VALUES [("-170141183460469231731687303715884105728"), ("100")),\nPARTITION p2 VALUES [("100"), ("200")),\nPARTITION p3 VALUES [("200"), ("300")),\nPARTITION p4 VALUES [("300"), ("400")),\nPARTITION p5 VALUES [("400"), ("500")),\nPARTITION p6 VALUES [("500"), ("600")),\nPARTITION p7 VALUES [("600"), (MAXVALUE)))\nDISTRIBUTED BY HASH(`user_id`) BUCKETS 2\nPROPERTIES (\n"replication_allocation" = "tag.location.default: 1",\n"min_load_replica_num" = "-1",\n"is_being_synced" = "false",\n"storage_medium" = "hdd",\n"storage_format" = "V2",\n"inverted_index_storage_format" = "V1",\n"light_schema_change" = "true",\n"disable_auto_compaction" = "false",\n"enable_single_replica_compaction" = "false",\n"group_commit_interval_ms" = "10000",\n"group_commit_data_bytes" = "134217728"\n); - diff --git a/regression-test/suites/show_p0/test_show_create_table_and_views.groovy b/regression-test/suites/show_p0/test_show_create_table_and_views.groovy index 2814ba8cd8ac29..6c6322e5c4aa03 100644 --- a/regression-test/suites/show_p0/test_show_create_table_and_views.groovy +++ b/regression-test/suites/show_p0/test_show_create_table_and_views.groovy @@ -16,7 +16,6 @@ // under the License. suite("test_show_create_table_and_views", "show") { - sql "SET enable_nereids_planner=false;" def ret = sql "SHOW FRONTEND CONFIG like '%enable_feature_binlog%';" logger.info("${ret}") if (ret.size() != 0 && ret[0].size() > 1 && ret[0][1] == 'false') { diff --git a/regression-test/suites/show_p0/test_show_create_table_and_views_nereids.groovy b/regression-test/suites/show_p0/test_show_create_table_and_views_nereids.groovy deleted file mode 100644 index aa235b2b188afd..00000000000000 --- a/regression-test/suites/show_p0/test_show_create_table_and_views_nereids.groovy +++ /dev/null @@ -1,126 +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_show_create_table_and_views_nereids", "show") { - sql "SET enable_nereids_planner=true;" - sql "SET enable_fallback_to_original_planner=false;" - def ret = sql "SHOW FRONTEND CONFIG like '%enable_feature_binlog%';" -// logger.info("${ret}") -// if (ret.size() != 0 && ret[0].size() > 1 && ret[0][1] == 'false') { -// logger.info("enable_feature_binlog=false in frontend config, no need to run this case.") -// return -// } - - String suiteName = "show_create_table_and_views" - String dbName = "${suiteName}_db" - String tableName = "${suiteName}_table" - String viewName = "${suiteName}_view" - String rollupName = "${suiteName}_rollup" - String likeName = "${suiteName}_like" - - sql "CREATE DATABASE IF NOT EXISTS ${dbName}" - sql "DROP TABLE IF EXISTS ${dbName}.${tableName}" - sql """ - CREATE TABLE ${dbName}.${tableName} ( - `user_id` LARGEINT NOT NULL, - `good_id` LARGEINT NOT NULL, - `cost` BIGINT SUM DEFAULT "0" - ) - AGGREGATE KEY(`user_id`, `good_id`) - PARTITION BY RANGE(`good_id`) - ( - PARTITION p1 VALUES LESS THAN ("100"), - PARTITION p2 VALUES LESS THAN ("200"), - PARTITION p3 VALUES LESS THAN ("300"), - PARTITION p4 VALUES LESS THAN ("400"), - PARTITION p5 VALUES LESS THAN ("500"), - PARTITION p6 VALUES LESS THAN ("600"), - PARTITION p7 VALUES LESS THAN MAXVALUE - ) - DISTRIBUTED BY HASH(`user_id`) BUCKETS 2 - PROPERTIES ( - "replication_num" = "1" - ) - """ - - sql """INSERT INTO ${dbName}.${tableName} VALUES - (1, 1, 10), - (1, 1, 20), - (1, 2, 5), - (1, 3, 10), - (2, 1, 0), - (2, 1, 100), - (3, 1, 10), - (2, 2, 10), - (2, 3, 44), - (3, 2, 1), - (100, 100, 1), - (200, 20, 1), - (300, 20, 1), - (1, 300, 2), - (2, 200, 1111), - (23, 900, 1)""" - - qt_show "SHOW CREATE TABLE ${dbName}.${tableName}" - qt_select "SELECT * FROM ${dbName}.${tableName} ORDER BY user_id, good_id" - - // create view and show - sql """ - CREATE VIEW IF NOT EXISTS ${dbName}.${viewName} (user_id, cost) - AS - SELECT user_id, cost FROM ${dbName}.${tableName} - WHERE good_id = 2 - """ - qt_select "SELECT * FROM ${dbName}.${viewName} ORDER BY user_id" - qt_show "SHOW CREATE VIEW ${dbName}.${viewName}" - - // create rollup - sql """ALTER TABLE ${dbName}.${tableName} - ADD ROLLUP ${rollupName} (user_id, cost) - """ - - def isAlterTableFinish = { -> - def records = sql """SHOW ALTER TABLE ROLLUP FROM ${dbName}""" - for (def row in records) { - if (row[5] == "${rollupName}" && row[8] == "FINISHED") { - return true - } - } - false - } - while (!isAlterTableFinish()) { - Thread.sleep(100) - } - - qt_select "SELECT user_id, SUM(cost) FROM ${dbName}.${tableName} GROUP BY user_id ORDER BY user_id" - qt_show "SHOW CREATE TABLE ${dbName}.${tableName}" - - // create like - sql "CREATE TABLE ${dbName}.${likeName} LIKE ${dbName}.${tableName}" - qt_show "SHOW CREATE TABLE ${dbName}.${likeName}" - - // create like with rollup - sql "CREATE TABLE ${dbName}.${likeName}_with_rollup LIKE ${dbName}.${tableName} WITH ROLLUP" - qt_show "SHOW CREATE TABLE ${dbName}.${likeName}_with_rollup" - - sql "DROP TABLE IF EXISTS ${dbName}.${likeName}_with_rollup FORCE" - sql "DROP TABLE ${dbName}.${likeName} FORCE" - sql "DROP VIEW ${dbName}.${viewName}" - sql "DROP TABLE ${dbName}.${tableName} FORCE" - sql "DROP DATABASE ${dbName} FORCE" -} -