Skip to content

Commit 250d2f1

Browse files
cfmcgradyulysses-you
authored andcommitted
[KYUUBI #1776] Improve EnginePage
<!-- Thanks for sending a pull request! Here are some tips for you: 1. If this is your first time, please read our contributor guidelines: https://kyuubi.readthedocs.io/en/latest/community/contributions.html 2. If the PR is related to an issue in https://github.com/apache/incubator-kyuubi/issues, add '[KYUUBI #XXXX]' in your PR title, e.g., '[KYUUBI #XXXX] Your PR title ...'. 3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][KYUUBI #XXXX] Your PR title ...'. --> ### _Why are the changes needed?_ <!-- Please clarify why the changes are needed. For instance, 1. If you add a feature, you can talk about the use case of it. 2. If you fix a bug, you can clarify why it is a bug. --> Improve the UI page of `Kyuubi Query Engine`. Currently, the column named `Query Execution` in tab `SQL Statistics` is not readable 1. Replace column `Query Execution` with `Query Details` and point it to the Spark SQL detail page 2. Add a new column `Failure Reason` to display an exception message when the query fails. ### _How was this patch tested?_ - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [x] Add screenshots for manual tests if appropriate ![截屏2022-01-17 下午2 53 43](https://user-images.githubusercontent.com/8537877/149723476-7dd1aaab-b141-4ca3-a824-cbd393378dd8.png) - [ ] [Run test](https://kyuubi.readthedocs.io/en/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #1776 from cfmcgrady/ui. Closes #1776 efab75a [Fu Chen] trigger GitHub actions 5b7001b [Fu Chen] fix ut d9ccff8 [Fu Chen] fix style 717b916 [Fu Chen] Improve EnginePage Authored-by: Fu Chen <cfmcgrady@gmail.com> Signed-off-by: ulysses-you <ulyssesyou@apache.org>
1 parent 7dcddaf commit 250d2f1

File tree

6 files changed

+34
-18
lines changed

6 files changed

+34
-18
lines changed

externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/events/SparkOperationEvent.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package org.apache.kyuubi.engine.spark.events
1919

20-
import org.apache.spark.sql.{DataFrame, Encoders}
20+
import org.apache.spark.sql.Encoders
2121
import org.apache.spark.sql.types.StructType
2222

2323
import org.apache.kyuubi.Utils
@@ -42,7 +42,7 @@ import org.apache.kyuubi.engine.spark.operation.SparkOperation
4242
* @param exception: caught exception if have
4343
* @param sessionId the identifier of the parent session
4444
* @param sessionUser the authenticated client user
45-
* @param queryExecution the query execution of this operation
45+
* @param executionId the query execution id of this operation
4646
*/
4747
case class SparkOperationEvent(
4848
statementId: String,
@@ -56,7 +56,7 @@ case class SparkOperationEvent(
5656
exception: Option[Throwable],
5757
sessionId: String,
5858
sessionUser: String,
59-
queryExecution: String) extends KyuubiSparkEvent {
59+
executionId: Option[Long]) extends KyuubiSparkEvent {
6060

6161
override def schema: StructType = Encoders.product[SparkOperationEvent].schema
6262
override def partitions: Seq[(String, String)] =
@@ -72,7 +72,9 @@ case class SparkOperationEvent(
7272
}
7373

7474
object SparkOperationEvent {
75-
def apply(operation: SparkOperation, result: Option[DataFrame] = None): SparkOperationEvent = {
75+
def apply(
76+
operation: SparkOperation,
77+
executionId: Option[Long] = None): SparkOperationEvent = {
7678
val session = operation.getSession
7779
val status = operation.getStatus
7880
new SparkOperationEvent(
@@ -87,6 +89,6 @@ object SparkOperationEvent {
8789
status.exception,
8890
session.handle.identifier.toString,
8991
session.user,
90-
result.map(_.queryExecution.toString).orNull)
92+
executionId)
9193
}
9294
}

externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/operation/ExecuteStatement.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ class ExecuteStatement(
146146

147147
override def setState(newState: OperationState): Unit = {
148148
super.setState(newState)
149-
EventLoggingService.onEvent(SparkOperationEvent(this, Option(result)))
149+
EventLoggingService.onEvent(
150+
SparkOperationEvent(this, operationListener.getExecutionId))
150151
}
151152
}

externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/spark/kyuubi/SQLOperationListener.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class SQLOperationListener(
4444
private val activeStages = new java.util.HashSet[Int]()
4545
private var executionId: Option[Long] = None
4646

47+
def getExecutionId: Option[Long] = executionId
48+
4749
// For broadcast, Spark will introduce a new runId as SPARK_JOB_GROUP_ID, see:
4850
// https://github.com/apache/spark/pull/24595, So we will miss these logs.
4951
// TODO: Fix this until the below ticket resolved

externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/spark/ui/EnginePage.scala

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ private class StatementStatsPagedTable(
327327
("Duration", true, None),
328328
("Statement", true, None),
329329
("State", true, None),
330-
("Query Execution", true, None))
330+
("Query Details", true, None),
331+
("Failure Reason", true, None))
331332

332333
headerStatRow(
333334
sqlTableHeadersAndTooltips,
@@ -365,8 +366,19 @@ private class StatementStatsPagedTable(
365366
{event.state}
366367
</td>
367368
<td>
368-
{event.queryExecution}
369+
{
370+
if (event.executionId.isDefined) {
371+
<a href={
372+
"%s/SQL/execution/?id=%s".format(
373+
UIUtils.prependBaseUri(request, parent.basePath),
374+
event.executionId.get)
375+
}>
376+
{event.executionId.get}
377+
</a>
378+
}
379+
}
369380
</td>
381+
{if (event.exception.isDefined) errorMessageCell(event.exception.get.getMessage)}
370382
</tr>
371383
}
372384

@@ -447,7 +459,6 @@ private class StatementStatsTableDataSource(
447459
case "Duration" => Ordering.by(_.duration)
448460
case "Statement" => Ordering.by(_.statement)
449461
case "State" => Ordering.by(_.state)
450-
case "Query Execution" => Ordering.by(_.queryExecution)
451462
case unknownColumn => throw new IllegalArgumentException(s"Unknown column: $unknownColumn")
452463
}
453464
if (desc) {

externals/kyuubi-spark-sql-engine/src/test/scala/org/apache/kyuubi/engine/spark/events/EngineEventsStoreSuite.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class EngineEventsStoreSuite extends KyuubiFunSuite {
9494
None,
9595
"sid1",
9696
"a",
97-
"")
97+
None)
9898
val s2 = SparkOperationEvent(
9999
"ea2",
100100
"select 2",
@@ -107,7 +107,7 @@ class EngineEventsStoreSuite extends KyuubiFunSuite {
107107
None,
108108
"sid1",
109109
"c",
110-
"")
110+
None)
111111
val s3 = SparkOperationEvent(
112112
"ea3",
113113
"select 3",
@@ -120,7 +120,7 @@ class EngineEventsStoreSuite extends KyuubiFunSuite {
120120
None,
121121
"sid1",
122122
"b",
123-
"")
123+
None)
124124

125125
store.saveStatement(s1)
126126
store.saveStatement(s2)
@@ -149,7 +149,7 @@ class EngineEventsStoreSuite extends KyuubiFunSuite {
149149
None,
150150
"sid1",
151151
"a",
152-
"")
152+
None)
153153
store.saveStatement(s)
154154
}
155155

@@ -174,7 +174,7 @@ class EngineEventsStoreSuite extends KyuubiFunSuite {
174174
None,
175175
"sid1",
176176
"a",
177-
""))
177+
None))
178178
store.saveStatement(SparkOperationEvent(
179179
"s2",
180180
"select 1",
@@ -187,7 +187,7 @@ class EngineEventsStoreSuite extends KyuubiFunSuite {
187187
None,
188188
"sid1",
189189
"a",
190-
""))
190+
None))
191191
store.saveStatement(SparkOperationEvent(
192192
"s3",
193193
"select 1",
@@ -200,7 +200,7 @@ class EngineEventsStoreSuite extends KyuubiFunSuite {
200200
None,
201201
"sid1",
202202
"a",
203-
""))
203+
None))
204204
store.saveStatement(SparkOperationEvent(
205205
"s4",
206206
"select 1",
@@ -213,7 +213,7 @@ class EngineEventsStoreSuite extends KyuubiFunSuite {
213213
None,
214214
"sid1",
215215
"a",
216-
""))
216+
None))
217217

218218
assert(store.getStatementList.size == 3)
219219
assert(store.getStatementList(2).statementId == "s4")

externals/kyuubi-spark-sql-engine/src/test/scala/org/apache/spark/ui/EngineTabSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class EngineTabSuite extends WithSparkSQLEngine with HiveJDBCTestHelper {
133133
assert(resp.contains("sqlstat"))
134134

135135
// check sql stats table title
136-
assert(resp.contains("Query Execution"))
136+
assert(resp.contains("Query Details"))
137137
}
138138
}
139139

0 commit comments

Comments
 (0)