Skip to content

Commit c3f6c58

Browse files
yaooqinndongjoon-hyun
authored andcommitted
[SPARK-50872][SQL][UI] Makes ToPrettyString expression not affect UI presentation
### What changes were proposed in this pull request? The Plan graph and plan detail are affected by the injected ToPrettyString expression. They are not consistent with the output of our `explain` API. If there are a lot of output columns, the UI looks malformed. ![image](https://github.com/user-attachments/assets/f7f32369-b5c5-47d3-b320-ffaff55867a6) ### Why are the changes needed? It's not good to keep noise on the user's daily debug tool ### Does this PR introduce _any_ user-facing change? No, this only changes the ongoing 4.0 ### How was this patch tested? Added UT and UI manual test ![image](https://github.com/user-attachments/assets/f851096a-b952-419e-9062-3995e6b1697c) ### Was this patch authored or co-authored using generative AI tooling? no Closes #49551 from yaooqinn/SPARK-50872. Authored-by: Kent Yao <yao@apache.org> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
1 parent b104db9 commit c3f6c58

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/ToPrettyString.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,6 @@ case class ToPrettyString(child: Expression, timeZoneId: Option[String] = None)
7373
|""".stripMargin
7474
ev.copy(code = finalCode, isNull = FalseLiteral)
7575
}
76+
77+
override def sql: String = child.sql
7678
}

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ToPrettyStringSuite.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,10 @@ class ToPrettyStringSuite extends SparkFunSuite with ExpressionEvalHelper {
128128
val v = new VariantVal(Array[Byte](1, 2, 3), Array[Byte](1, 1))
129129
checkEvaluation(ToPrettyString(Literal(v)), UTF8String.fromString(v.toString))
130130
}
131+
132+
test("sql method is equalivalent to child's sql") {
133+
val child = Literal(1)
134+
val prettyString = ToPrettyString(child)
135+
assert(prettyString.sql === child.sql)
136+
}
131137
}

0 commit comments

Comments
 (0)