This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new 347277f63a5 branch-3.0: [Fix](insert-job)Fix Issue with Missing 
StatementContext in StmtExecutor, Leading to Incorrect SQL_BLOCK Handling 
#46715 (#46739)
347277f63a5 is described below

commit 347277f63a5d3aff348b3f9c4022ef019bc13e0e
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Jan 10 20:16:26 2025 +0800

    branch-3.0: [Fix](insert-job)Fix Issue with Missing StatementContext in 
StmtExecutor, Leading to Incorrect SQL_BLOCK Handling #46715 (#46739)
    
    Cherry-picked from #46715
    
    Co-authored-by: Calvin Kirs <[email protected]>
---
 .../org/apache/doris/job/extensions/insert/InsertTask.java |  6 +++++-
 regression-test/suites/job_p0/test_base_insert_job.groovy  | 14 ++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

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 883c4265316..ff18f611c1e 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
@@ -29,6 +29,8 @@ import org.apache.doris.job.task.AbstractTask;
 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 class InsertTask extends AbstractTask {
             ctx.setDatabase(currentDb);
         }
         TUniqueId queryId = generateQueryId(UUID.randomUUID().toString());
-        stmtExecutor = new StmtExecutor(ctx, (String) null);
+        StatementContext statementContext = new StatementContext();
         ctx.setQueryId(queryId);
+        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 1703b355c95..042546d1e43 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}'


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to