linhongliu-db commented on code in PR #39268:
URL: https://github.com/apache/spark/pull/39268#discussion_r1061140864


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/SQLExecution.scala:
##########
@@ -55,6 +56,28 @@ object SQLExecution {
     }
   }
 
+  /**
+   * Track the "root" SQL Execution Id for nested/sub queries.
+   * For the root execution, rootExecutionId == executionId.
+   */
+  private def setRootExecutionId(sc: SparkContext, executionId: String): Unit 
= {
+    // The current execution is the root execution if the root execution ID is 
null
+    if (sc.getLocalProperty(EXECUTION_ROOT_ID_KEY) == null) {
+      sc.setLocalProperty(EXECUTION_ROOT_ID_KEY, executionId)
+    }
+  }
+
+  /**
+   * Unset the "root" SQL Execution Id once the "root" SQL execution completes.
+   */
+  private def unsetRootExecutionId(sc: SparkContext, executionId: String): 
Unit = {

Review Comment:
   yes, it's only used once. I personally think that using a function can 
better explain the logic since it's not a no-brainer.



##########
sql/core/src/main/scala/org/apache/spark/sql/execution/ui/AllExecutionsPage.scala:
##########
@@ -26,40 +26,63 @@ import scala.xml.{Node, NodeSeq}
 
 import org.apache.spark.JobExecutionStatus
 import org.apache.spark.internal.Logging
+import org.apache.spark.internal.config.UI.UI_SQL_GROUP_SUB_EXECUTION_ENABLED
 import org.apache.spark.sql.errors.QueryExecutionErrors
 import org.apache.spark.ui.{PagedDataSource, PagedTable, UIUtils, WebUIPage}
 import org.apache.spark.util.Utils
 
 private[ui] class AllExecutionsPage(parent: SQLTab) extends WebUIPage("") with 
Logging {
 
   private val sqlStore = parent.sqlStore
+  private val groupSubExecutionEnabled = 
parent.conf.get(UI_SQL_GROUP_SUB_EXECUTION_ENABLED)
 
   override def render(request: HttpServletRequest): Seq[Node] = {
     val currentTime = System.currentTimeMillis()
     val running = new mutable.ArrayBuffer[SQLExecutionUIData]()
     val completed = new mutable.ArrayBuffer[SQLExecutionUIData]()
     val failed = new mutable.ArrayBuffer[SQLExecutionUIData]()
+    val executionIdToSubExecutions =
+      new mutable.HashMap[Long, mutable.ArrayBuffer[SQLExecutionUIData]]()
 
     sqlStore.executionsList().foreach { e =>
-      if (e.errorMessage.isDefined) {
-        if (e.errorMessage.get.isEmpty) {
-          completed += e
+      def processExecution(e: SQLExecutionUIData): Unit = {
+        if (e.errorMessage.isDefined) {
+          if (e.errorMessage.get.isEmpty) {
+            completed += e
+          } else {
+            failed += e
+          }
+        } else if (e.completionTime.isEmpty) {
+          running += e
         } else {
-          failed += e
+          // When `completionTime` is present, it means the query execution is 
completed and
+          // `errorMessage` should be present as well. However, events 
generated by old versions of
+          // Spark do not have the `errorMessage` field. We have to check the 
status of this query

Review Comment:
   we have this one: 
https://github.com/apache/spark/blob/master/sql/core/src/test/scala/org/apache/spark/sql/execution/ui/AllExecutionsPageSuite.scala#L69



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to