Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
924060929 committed Dec 10, 2024
1 parent ad4717e commit 0ca3c8f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public class InsertIntoTableCommand extends Command implements ForwardWithSync,
public static final Logger LOG = LogManager.getLogger(InsertIntoTableCommand.class);

private LogicalPlan originLogicalQuery;
private LogicalPlan logicalQuery;
private Optional<LogicalPlan> logicalQuery;
private Optional<CascadesContext> analyzeContext;
private Optional<String> labelName;
/**
Expand All @@ -122,13 +122,14 @@ public InsertIntoTableCommand(LogicalPlan logicalQuery, Optional<String> labelNa
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.analyzeContext = Optional.empty();
this.insertCtx = insertCtx;
this.cte = cte;
}

public LogicalPlan getLogicalQuery() {
return logicalQuery == null ? originLogicalQuery : logicalQuery;
return logicalQuery.orElse(originLogicalQuery);
}

public Optional<String> getLabelName() {
Expand Down Expand Up @@ -188,13 +189,14 @@ public AbstractInsertExecutor initPlan(ConnectContext ctx, StmtExecutor stmtExec
);

// 1. process inline table (default values, empty values)
this.logicalQuery = (LogicalPlan) InsertUtils.normalizePlan(
this.logicalQuery = Optional.of((LogicalPlan) InsertUtils.normalizePlan(
originLogicalQuery, targetTableIf, analyzeContext, insertCtx
);
));
if (cte.isPresent()) {
this.logicalQuery = ((LogicalPlan) cte.get().withChildren(logicalQuery));
this.logicalQuery = Optional.of((LogicalPlan) cte.get().withChildren(logicalQuery.get()));
}
OlapGroupCommitInsertExecutor.analyzeGroupCommit(ctx, targetTableIf, this.logicalQuery, this.insertCtx);
LogicalPlan logicalQuery = this.logicalQuery.get();
OlapGroupCommitInsertExecutor.analyzeGroupCommit(ctx, targetTableIf, logicalQuery, this.insertCtx);
LogicalPlanAdapter logicalPlanAdapter = new LogicalPlanAdapter(logicalQuery, ctx.getStatementContext());

BuildInsertExecutorResult buildResult = planInsertExecutor(
Expand Down Expand Up @@ -401,12 +403,12 @@ private void runInternal(ConnectContext ctx, StmtExecutor executor) throws Excep
}

public boolean isExternalTableSink() {
return !(logicalQuery instanceof UnboundTableSink);
return !(getLogicalQuery() instanceof UnboundTableSink);
}

@Override
public Plan getExplainPlan(ConnectContext ctx) {
return InsertUtils.getPlanForExplain(ctx, this.analyzeContext, this.logicalQuery);
return InsertUtils.getPlanForExplain(ctx, this.analyzeContext, getLogicalQuery());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ suite("insert_group_commit_with_exception") {
assertTrue(false)
} catch (Exception e) {
logger.info("exception : " + e)
assertTrue(e.getMessage().contains("insert into cols should be corresponding to the query output"))
assertTrue(e.getMessage().contains("Column count doesn't match value count"))
}
}
getRowCount(14)
Expand Down

0 comments on commit 0ca3c8f

Please sign in to comment.