Skip to content

Commit

Permalink
branch-2.1:[Fix](insert-job)Fix Issue with Missing StatementContext i…
Browse files Browse the repository at this point in the history
…n StmtExecutor, Leading to Incorrect SQL_BLOCK Handling (#46715) (#46757)

…
#46715
  • Loading branch information
CalvinKirs authored Jan 10, 2025
1 parent bd64566 commit ed3727b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.apache.doris.load.FailMsg;
import org.apache.doris.load.loadv2.LoadJob;
import org.apache.doris.load.loadv2.LoadStatistic;
import org.apache.doris.nereids.StatementContext;
import org.apache.doris.nereids.glue.LogicalPlanAdapter;
import org.apache.doris.nereids.parser.NereidsParser;
import org.apache.doris.nereids.trees.plans.commands.insert.InsertIntoTableCommand;
import org.apache.doris.qe.ConnectContext;
Expand Down Expand Up @@ -159,13 +161,15 @@ public void before() throws JobException {
TUniqueId queryId = generateQueryId(UUID.randomUUID().toString());
ctx.getSessionVariable().enableFallbackToOriginalPlanner = false;
ctx.getSessionVariable().enableNereidsDML = true;
stmtExecutor = new StmtExecutor(ctx, (String) null);
ctx.setQueryId(queryId);
StatementContext statementContext = new StatementContext();
ctx.setStatementContext(statementContext);
if (StringUtils.isNotEmpty(sql)) {
NereidsParser parser = new NereidsParser();
this.command = (InsertIntoTableCommand) parser.parseSingle(sql);
this.command.setLabelName(Optional.of(getJobId() + LABEL_SPLITTER + getTaskId()));
this.command.setJobId(getTaskId());
stmtExecutor = new StmtExecutor(ctx, new LogicalPlanAdapter(command, ctx.getStatementContext()));
}

super.before();
Expand Down
14 changes: 14 additions & 0 deletions regression-test/suites/job_p0/test_base_insert_job.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ suite("test_base_insert_job") {
"replication_allocation" = "tag.location.default: 1"
);
"""
sql """
DROP SQL_BLOCK_RULE IF EXISTS test_base_insert_job_rule
"""
sql """
CREATE SQL_BLOCK_RULE test_base_insert_job_rule
PROPERTIES(
"sql"="select \\\\* from test_base_insert_job_rule",
"global"="true",
"enable"="true"
);
"""
sql """
insert into ${tableName} values
('2023-03-18', 1, 1)
Expand Down Expand Up @@ -242,6 +253,9 @@ suite("test_base_insert_job") {
//resume tasks size should be greater than before pause
afterResumeTasks.size() > tasks.size()
})
sql """
DROP SQL_BLOCK_RULE IF EXISTS test_base_insert_job_rule
"""
// check resume job status
def afterResumeJobStatus = sql """
select status from jobs("type"="insert") where Name='${jobName}'
Expand Down

0 comments on commit ed3727b

Please sign in to comment.