From 5ca3ffd85e5286c914fefa246d93801b5f7f235c Mon Sep 17 00:00:00 2001 From: 924060929 Date: Fri, 22 Nov 2024 11:46:55 +0800 Subject: [PATCH] rebase --- .../insert/InsertIntoTableCommand.java | 24 +++++++------------ .../plans/commands/insert/InsertUtils.java | 1 - 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertIntoTableCommand.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertIntoTableCommand.java index a147a900f02b67..bdb7eb573fd55d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertIntoTableCommand.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertIntoTableCommand.java @@ -38,8 +38,10 @@ import org.apache.doris.nereids.memo.Group; import org.apache.doris.nereids.memo.GroupId; import org.apache.doris.nereids.properties.PhysicalProperties; +import org.apache.doris.nereids.rules.Rule; import org.apache.doris.nereids.rules.RuleType; import org.apache.doris.nereids.rules.analysis.BindSink; +import org.apache.doris.nereids.rules.implementation.LogicalOlapTableSinkToPhysicalOlapTableSink; import org.apache.doris.nereids.rules.rewrite.MergeProjects; import org.apache.doris.nereids.trees.expressions.Slot; import org.apache.doris.nereids.trees.plans.Explainable; @@ -350,8 +352,6 @@ private BuildInsertExecutorResult planInsertExecutor( // 3. NereidsPlanner use PhysicalPlan and the provided backend to generate DistributePlan // 4. ExecutorFactory use the DistributePlan to generate the NereidsSqlCoordinator and InsertExecutor - StatementContext statementContext = ctx.getStatementContext(); - AtomicReference executorFactoryRef = new AtomicReference<>(); InsertByInlineTablePlanner planner = new InsertByInlineTablePlanner(ctx.getStatementContext()) { @Override @@ -466,6 +466,8 @@ public BuildInsertExecutorResult(NereidsPlanner planner, AbstractInsertExecutor } private static class InsertByInlineTablePlanner extends NereidsPlanner { + private static final Rule toPhysicalOlapTableSink = new LogicalOlapTableSinkToPhysicalOlapTableSink() + .build(); private AtomicReference rootGroupRef = new AtomicReference<>(); public InsertByInlineTablePlanner(StatementContext statementContext) { @@ -527,6 +529,7 @@ public Plan visitLogicalProject(LogicalProject project, Void con @Override protected void optimize() { DefaultPlanRewriter optimizer = new DefaultPlanRewriter() { + @Override public Plan visitLogicalUnion(LogicalUnion logicalUnion, Void context) { logicalUnion = (LogicalUnion) super.visitLogicalUnion(logicalUnion, context); @@ -557,20 +560,9 @@ public Plan visitLogicalOlapTableSink(LogicalOlapTableSink olapT Void context) { olapTableSink = (LogicalOlapTableSink) super.visitLogicalOlapTableSink(olapTableSink, context); - - return new PhysicalOlapTableSink<>( - olapTableSink.getDatabase(), - olapTableSink.getTargetTable(), - olapTableSink.getCols(), - olapTableSink.getPartitionIds(), - olapTableSink.getOutputExprs(), - getCascadesContext().getConnectContext().getSessionVariable().isEnableSingleReplicaInsert(), - olapTableSink.isPartialUpdate(), - olapTableSink.getDmlCommandType(), - Optional.empty(), - olapTableSink.getLogicalProperties(), - olapTableSink.child() - ); + return toPhysicalOlapTableSink + .transform(olapTableSink, getCascadesContext()) + .get(0); } }; diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertUtils.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertUtils.java index 51dc49d83290e9..db8dfe603a1644 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertUtils.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertUtils.java @@ -34,7 +34,6 @@ import org.apache.doris.nereids.analyzer.UnboundHiveTableSink; import org.apache.doris.nereids.analyzer.UnboundIcebergTableSink; import org.apache.doris.nereids.analyzer.UnboundJdbcTableSink; -import org.apache.doris.nereids.analyzer.UnboundOneRowRelation; import org.apache.doris.nereids.analyzer.UnboundTableSink; import org.apache.doris.nereids.exceptions.AnalysisException; import org.apache.doris.nereids.parser.NereidsParser;