Repository navigation
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change preserving multi-line SQL formatting in the Kyuubi UI.
No open issues 🎉
What changed in this PR
Preserves multi-line SQL formatting in the Spark UI’s Kyuubi tab, covering both engine and session statement tables.
Changes:
- Keeps the collapsed statement preview and adds expandable, preformatted details using Spark’s existing
detailsUINodehelper. - Adds a test that checks the statement appears in both the preview and a formatting-preserving
<pre>block.
| File | Description |
|---|---|
| externals/kyuubi-spark-sql-engine/src/test/scala/org/apache/spark/ui/EngineTabSuite.scala | Adds coverage for multi-line statement rendering. |
| externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/spark/ui/EnginePage.scala | Adds collapsible, preformatted statement details to the shared table. |
Review effort: Balanced
|
but leading spaces are still lost? |
pan3793
left a comment
There was a problem hiding this comment.
Thanks for confirming! The missing indentation in the first screenshot was probably from Beeline, since KyuubiCommands.handleMultiLineCmd calls HiveStringUtils.removeComments on each line, which ends with .trim().
The change looks good overall, just two minor suggestions below.
| * similar to the description cell of Spark's SQL tab. | ||
| */ | ||
| private def statementCell(statement: String): Seq[Node] = { | ||
| val isMultiline = statement.trim.indexOf('\n') >= 0 |
There was a problem hiding this comment.
Guard against null here (e.g., val stmt = Option(statement).getOrElse("")) to avoid an NPE on deserialized events in KyuubiHistoryServerPlugin; previously {event.statement} rendered null as empty text.
| assert(resp.contains("Completed Statement Statistics")) | ||
| } | ||
|
|
||
| test("multi-line statement keeps original format in engine tab") { |
There was a problem hiding this comment.
Consider also executing a single-line statement (e.g., "\nSELECT 1\n") in the same test case and asserting it does not render <pre>, so both branches of isMultiline (including .trim) are covered without an extra engine restart.
…engine UI ### Why are the changes needed? The Statement column in the Kyuubi tab of the Spark UI uses Spark's `description-input` CSS class. Its `white-space` is `nowrap` when collapsed and `normal` when expanded, so line breaks and indentation are lost in both states and long multi-line SQL is hard to read. This PR follows the description cell of Spark's SQL tab: the cell still holds the full statement truncated to one line, and multi-line statements get a `+details` toggle that shows the statement in its original format inside a `<pre>` block. It reuses Spark's `UIUtils.detailsUINode`, which also renders the failure reason details, so no new CSS or JS is needed. The statement table is shared by the engine page and the session page, so both are covered. ### How was this patch tested? Add UT local test Master <img width="4496" height="2094" alt="master" src="https://github.com/user-attachments/assets/d2ee5c5c-7189-4038-a4fb-3194c709ea07" /> PR <img width="4496" height="2524" alt="PR" src="https://github.com/user-attachments/assets/56edecd1-b606-424e-bc4c-ab4a5678a09a" /> ### Was this patch assisted by generative AI tooling? Assisted-by: Claude:claude-opus-5-5 Closes #7878 from cxzl25/spark-ui-statement-preserve-format. Closes #7878 149deba [sychen] address 721f4c1 [sychen] ui Authored-by: cxzl25 <sychen@ctrip.com> Signed-off-by: Cheng Pan <chengpan@apache.org> (cherry picked from commit dfd0f7a) Signed-off-by: Cheng Pan <chengpan@apache.org>


Why are the changes needed?
The Statement column in the Kyuubi tab of the Spark UI uses Spark's
description-inputCSS class. Itswhite-spaceisnowrapwhen collapsed andnormalwhen expanded, so line breaks and indentation are lost in both states and long multi-line SQL is hard to read.This PR follows the description cell of Spark's SQL tab: the cell still holds the full statement truncated to one line, and multi-line statements get a
+detailstoggle that shows the statement in its original format inside a<pre>block. It reuses Spark'sUIUtils.detailsUINode, which also renders the failure reason details, so no new CSS or JS is needed. The statement table is shared by the engine page and the session page, so both are covered.How was this patch tested?
Add UT
local test
Master
PR
Was this patch assisted by generative AI tooling?
Assisted-by: Claude:claude-opus-5-5