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

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

commit cb629f58bf36bbcd8a7c98235f8b0f35d6bd8ab0
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Sat Sep 26 19:50:55 2026 +0800

    branch-4.1: [fix](statistics) Fix NPE in SHOW ANALYZE TASK STATUS for 
missing job id #68469 (#68493)
    
    Cherry-picked from #68469
    
    Co-authored-by: yujun <[email protected]>
---
 .../doris/nereids/trees/plans/commands/ShowAnalyzeTaskCommand.java  | 3 +++
 .../suites/nereids_p0/show/test_show_analyze_task_status_cmd.groovy | 6 ++++++
 2 files changed, 9 insertions(+)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowAnalyzeTaskCommand.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowAnalyzeTaskCommand.java
index 1f7b6f82dab..5383fbdcfef 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowAnalyzeTaskCommand.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowAnalyzeTaskCommand.java
@@ -68,6 +68,9 @@ public class ShowAnalyzeTaskCommand extends ShowCommand {
                     + "in your FE conf file");
         }
         AnalysisInfo jobInfo = 
Env.getCurrentEnv().getAnalysisManager().findJobInfo(jobId);
+        if (jobInfo == null) {
+            throw new UserException(String.format("Analyze job [%d] not 
exists", jobId));
+        }
         TableIf table = StatisticsUtil.findTable(jobInfo.catalogId, 
jobInfo.dbId, jobInfo.tblId);
         List<AnalysisInfo> analysisInfos = 
Env.getCurrentEnv().getAnalysisManager().findTasks(jobId);
         List<List<String>> rows = new ArrayList<>();
diff --git 
a/regression-test/suites/nereids_p0/show/test_show_analyze_task_status_cmd.groovy
 
b/regression-test/suites/nereids_p0/show/test_show_analyze_task_status_cmd.groovy
index aa3750211d5..f6ccde1182c 100644
--- 
a/regression-test/suites/nereids_p0/show/test_show_analyze_task_status_cmd.groovy
+++ 
b/regression-test/suites/nereids_p0/show/test_show_analyze_task_status_cmd.groovy
@@ -37,6 +37,12 @@ suite("test_show_analyze_task_status_cmd", "nereids_p0") {
     // Insert some data
     sql """ INSERT INTO ${tableName} VALUES (1, 'a'), (2, 'b') """
 
+    // SHOW ANALYZE TASK STATUS for a non-existent job should report a clear 
error
+    test {
+        sql """ SHOW ANALYZE TASK STATUS 922337203685477 """
+        exception "Analyze job [922337203685477] not exists"
+    }
+
     // Run analyze asynchronously
     def analyzeResult = sql """ ANALYZE TABLE ${tableName} """
     assertTrue(analyzeResult.size() == 1, "Unexpected analyze result size")


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

Reply via email to