diff --git a/fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/InsertTask.java b/fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/InsertTask.java index 94484fdcd9b7f1..728f603d607f3e 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/InsertTask.java +++ b/fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/InsertTask.java @@ -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; @@ -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(); diff --git a/regression-test/suites/job_p0/test_base_insert_job.groovy b/regression-test/suites/job_p0/test_base_insert_job.groovy index 1703b355c95019..042546d1e430b4 100644 --- a/regression-test/suites/job_p0/test_base_insert_job.groovy +++ b/regression-test/suites/job_p0/test_base_insert_job.groovy @@ -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) @@ -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}'