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

yao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new 5d422155f1d [SPARK-45291][SQL][REST] Use unknown query execution id 
instead of no such app when id is invalid
5d422155f1d is described below

commit 5d422155f1dae09f1631375d09e2f3c8dffba9a5
Author: Kent Yao <y...@apache.org>
AuthorDate: Mon Sep 25 14:23:46 2023 +0800

    [SPARK-45291][SQL][REST] Use unknown query execution id instead of no such 
app when id is invalid
    
    ### What changes were proposed in this pull request?
    
    This PR fixes `/api/v1/applications/{appId}/sql/{executionId}` API when the 
executionId is invalid.
    
    Before this, we get `no such app: $appId`; after this, we get `unknown 
query execution id: $executionId`
    
    ### Why are the changes needed?
    
    bugfix
    
    ### Does this PR introduce _any_ user-facing change?
    
    no, bugfix
    
    ### How was this patch tested?
    
    new test
    ### Was this patch authored or co-authored using generative AI tooling?
    
    no
    
    Closes #43073 from yaooqinn/SPARK-45291.
    
    Authored-by: Kent Yao <y...@apache.org>
    Signed-off-by: Kent Yao <y...@apache.org>
---
 .../scala/org/apache/spark/status/api/v1/sql/SqlResource.scala   | 3 +--
 .../status/api/v1/sql/SqlResourceWithActualMetricsSuite.scala    | 9 +++++++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git 
a/sql/core/src/main/scala/org/apache/spark/status/api/v1/sql/SqlResource.scala 
b/sql/core/src/main/scala/org/apache/spark/status/api/v1/sql/SqlResource.scala
index 3c96f612da6..fa5bea5f9bb 100644
--- 
a/sql/core/src/main/scala/org/apache/spark/status/api/v1/sql/SqlResource.scala
+++ 
b/sql/core/src/main/scala/org/apache/spark/status/api/v1/sql/SqlResource.scala
@@ -56,10 +56,9 @@ private[v1] class SqlResource extends BaseAppResource {
       planDescription: Boolean): ExecutionData = {
     withUI { ui =>
       val sqlStore = new SQLAppStatusStore(ui.store.store)
-      val graph = sqlStore.planGraph(execId)
       sqlStore
         .execution(execId)
-        .map(prepareExecutionData(_, graph, details, planDescription))
+        .map(prepareExecutionData(_, sqlStore.planGraph(execId), details, 
planDescription))
         .getOrElse(throw new NotFoundException("unknown query execution id: " 
+ execId))
     }
   }
diff --git 
a/sql/core/src/test/scala/org/apache/spark/status/api/v1/sql/SqlResourceWithActualMetricsSuite.scala
 
b/sql/core/src/test/scala/org/apache/spark/status/api/v1/sql/SqlResourceWithActualMetricsSuite.scala
index 658f79fc289..c63c748953f 100644
--- 
a/sql/core/src/test/scala/org/apache/spark/status/api/v1/sql/SqlResourceWithActualMetricsSuite.scala
+++ 
b/sql/core/src/test/scala/org/apache/spark/status/api/v1/sql/SqlResourceWithActualMetricsSuite.scala
@@ -19,6 +19,7 @@ package org.apache.spark.status.api.v1.sql
 
 import java.net.URL
 import java.text.SimpleDateFormat
+import javax.servlet.http.HttpServletResponse
 
 import org.json4s.DefaultFormats
 import org.json4s.jackson.JsonMethods
@@ -148,4 +149,12 @@ class SqlResourceWithActualMetricsSuite
     }
   }
 
+  test("SPARK-45291: Use unknown query execution id instead of no such app 
when id is invalid") {
+    val url = new URL(spark.sparkContext.ui.get.webUrl +
+      
s"/api/v1/applications/${spark.sparkContext.applicationId}/sql/${Long.MaxValue}")
+    val (code, resultOpt, error) = getContentAndCode(url)
+    assert(code === HttpServletResponse.SC_NOT_FOUND)
+    assert(resultOpt.isEmpty)
+    assert(error.get === s"unknown query execution id: ${Long.MaxValue}")
+  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to