diff --git a/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/operation/SparkOperation.scala b/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/operation/SparkOperation.scala index da65d9f644b..ec9db84e48d 100644 --- a/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/operation/SparkOperation.scala +++ b/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/operation/SparkOperation.scala @@ -135,8 +135,9 @@ abstract class SparkOperation(session: Session) info(s"statementId=${statementId}, " + s"operationRunTime=${formatDuration(l.getOperationRunTime)}, " + s"operationCpuTime=${formatDuration(l.getOperationCpuTime / 1000000)}") - session.asInstanceOf[SparkSessionImpl].increaseRunTime(l.getOperationRunTime) - session.asInstanceOf[SparkSessionImpl].increaseCpuTime(l.getOperationCpuTime) + session.asInstanceOf[SparkSessionImpl].increaseRunAndCpuTime( + l.getOperationRunTime, + l.getOperationCpuTime) }) } } diff --git a/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/session/SparkSessionImpl.scala b/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/session/SparkSessionImpl.scala index e899c28c3ac..b0e2d91c53b 100644 --- a/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/session/SparkSessionImpl.scala +++ b/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/session/SparkSessionImpl.scala @@ -129,11 +129,8 @@ class SparkSessionImpl( handle) } - def increaseRunTime(time: Long): Unit = { - sessionRunTime.getAndAdd(time) - } - - def increaseCpuTime(time: Long): Unit = { - sessionCpuTime.getAndAdd(time) + def increaseRunAndCpuTime(runTime: Long, cpuTime: Long): Unit = { + sessionEvent.sessionRunTime = sessionRunTime.addAndGet(runTime) + sessionEvent.sessionCpuTime = sessionCpuTime.addAndGet(cpuTime) } } diff --git a/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/spark/ui/EnginePage.scala b/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/spark/ui/EnginePage.scala index cae0c03bf4d..d59b64dd9d2 100644 --- a/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/spark/ui/EnginePage.scala +++ b/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/spark/ui/EnginePage.scala @@ -402,6 +402,8 @@ case class EnginePage(parent: EngineTab) extends WebUIPage("") { ("Start Time", true, None), ("Finish Time", true, None), ("Duration", true, None), + ("Run Time", true, None), + ("CPU Time", true, None), ("Total Statements", true, None)) headerStatRow( @@ -428,6 +430,8 @@ case class EnginePage(parent: EngineTab) extends WebUIPage("") { {formatDate(session.startTime)} {if (session.endTime > 0) formatDate(session.endTime)} {formatDuration(session.duration)} + {formatDuration(session.sessionRunTime)} + {formatDuration(session.sessionCpuTime / 1000000)} {session.totalOperations} } @@ -484,6 +488,8 @@ private class StatementStatsPagedTable( ("Create Time", true, None), ("Finish Time", true, None), ("Duration", true, None), + ("Run Time", true, None), + ("CPU Time", true, None), ("Statement", true, None), ("State", true, None), ("Query Details", true, None), @@ -523,6 +529,8 @@ private class StatementStatsPagedTable( {formatDuration(event.duration)} + {formatDuration(event.operationRunTime.getOrElse(0L))} + {formatDuration(event.operationCpuTime.getOrElse(0L) / 1000000)} {event.statement} @@ -592,6 +600,8 @@ private class SessionStatsTableDataSource( case "Start Time" => Ordering.by(_.startTime) case "Finish Time" => Ordering.by(_.endTime) case "Duration" => Ordering.by(_.duration) + case "Run Time" => Ordering.by(_.sessionRunTime) + case "CPU Time" => Ordering.by(_.sessionCpuTime) case "Total Statements" => Ordering.by(_.totalOperations) case unknownColumn => throw new IllegalArgumentException(s"Unknown column: $unknownColumn") } @@ -627,6 +637,8 @@ private class StatementStatsTableDataSource( case "Create Time" => Ordering.by(_.createTime) case "Finish Time" => Ordering.by(_.completeTime) case "Duration" => Ordering.by(_.duration) + case "Run Time" => Ordering.by(_.operationRunTime.getOrElse(0L)) + case "CPU Time" => Ordering.by(_.operationCpuTime.getOrElse(0L)) case "Statement" => Ordering.by(_.statement) case "State" => Ordering.by(_.state) case "Query Details" => Ordering.by(_.executionId)