This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.1 by this push:
new 8876919a45d branch-3.1: [fix](nereids) fix insert overwrite statement
plan twice #53398 (#53474)
8876919a45d is described below
commit 8876919a45d356d04ea543b3fea0eef1ad0f2676
Author: 924060929 <[email protected]>
AuthorDate: Fri Jul 18 10:55:26 2025 +0800
branch-3.1: [fix](nereids) fix insert overwrite statement plan twice #53398
(#53474)
cherry pick from #53398
---
.../commands/insert/InsertIntoTableCommand.java | 20 ++++++++++++++++----
.../commands/insert/InsertOverwriteTableCommand.java | 2 +-
2 files changed, 17 insertions(+), 5 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 2e7d9d2eebd..29c81229e58 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
@@ -98,18 +98,26 @@ public class InsertIntoTableCommand extends Command
implements ForwardWithSync,
private long jobId;
private final Optional<InsertCommandContext> insertCtx;
private final Optional<LogicalPlan> cte;
+ private final boolean needNormalizePlan;
+
+ public InsertIntoTableCommand(LogicalPlan logicalQuery, Optional<String>
labelName,
+ Optional<InsertCommandContext> insertCtx, Optional<LogicalPlan>
cte) {
+ this(logicalQuery, labelName, insertCtx, cte, true);
+ }
/**
* constructor
*/
public InsertIntoTableCommand(LogicalPlan logicalQuery, Optional<String>
labelName,
- Optional<InsertCommandContext> insertCtx,
Optional<LogicalPlan> cte) {
+ Optional<InsertCommandContext> insertCtx,
Optional<LogicalPlan> cte,
+ boolean needNormalizePlan) {
super(PlanType.INSERT_INTO_TABLE_COMMAND);
this.originLogicalQuery = Objects.requireNonNull(logicalQuery,
"logicalQuery should not be null");
this.labelName = Objects.requireNonNull(labelName, "labelName should
not be null");
this.logicalQuery = Optional.empty();
this.insertCtx = insertCtx;
this.cte = cte;
+ this.needNormalizePlan = needNormalizePlan;
}
public LogicalPlan getLogicalQuery() {
@@ -235,9 +243,13 @@ public class InsertIntoTableCommand extends Command
implements ForwardWithSync,
CascadesContext.initContext(ctx.getStatementContext(),
originLogicalQuery, PhysicalProperties.ANY)
);
// process inline table (default values, empty values)
- this.logicalQuery = Optional.of((LogicalPlan)
InsertUtils.normalizePlan(
- originLogicalQuery, targetTableIf, analyzeContext,
insertCtx
- ));
+ if (needNormalizePlan) {
+ this.logicalQuery = Optional.of((LogicalPlan)
InsertUtils.normalizePlan(
+ originLogicalQuery, targetTableIf, analyzeContext,
insertCtx
+ ));
+ } else {
+ this.logicalQuery = Optional.of(originLogicalQuery);
+ }
if (cte.isPresent()) {
this.logicalQuery = Optional.of((LogicalPlan)
cte.get().withChildren(logicalQuery.get()));
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertOverwriteTableCommand.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertOverwriteTableCommand.java
index e8d6fcbb963..925de05998d 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertOverwriteTableCommand.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertOverwriteTableCommand.java
@@ -283,7 +283,7 @@ public class InsertOverwriteTableCommand extends Command
implements ForwardWithS
private void runInsertCommand(LogicalPlan logicalQuery,
InsertCommandContext insertCtx,
ConnectContext ctx, StmtExecutor executor) throws Exception {
InsertIntoTableCommand insertCommand = new
InsertIntoTableCommand(logicalQuery, labelName,
- Optional.of(insertCtx), Optional.empty());
+ Optional.of(insertCtx), Optional.empty(), false);
insertCommand.run(ctx, executor);
if (ctx.getState().getStateType() == MysqlStateType.ERR) {
String errMsg =
Strings.emptyToNull(ctx.getState().getErrorMessage());
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]