HyukjinKwon commented on a change in pull request #31372:
URL: https://github.com/apache/spark/pull/31372#discussion_r565822721



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/package.scala
##########
@@ -125,20 +125,34 @@ package object util extends Logging {
 
   // Replaces attributes, string literals, complex type extractors with their 
pretty form so that
   // generated column names don't contain back-ticks or double-quotes.
-  def usePrettyExpression(e: Expression): Expression = e transform {
-    case a: Attribute => new PrettyAttribute(a)
-    case Literal(s: UTF8String, StringType) => PrettyAttribute(s.toString, 
StringType)
-    case Literal(v, t: NumericType) if v != null => 
PrettyAttribute(v.toString, t)
-    case Literal(null, dataType) => PrettyAttribute("NULL", dataType)
-    case e: GetStructField =>
-      val name = e.name.getOrElse(e.childSchema(e.ordinal).name)
-      PrettyAttribute(usePrettyExpression(e.child).sql + "." + name, 
e.dataType)
-    case e: GetArrayStructFields =>
-      PrettyAttribute(usePrettyExpression(e.child) + "." + e.field.name, 
e.dataType)
-    case r: RuntimeReplaceable =>
-      PrettyAttribute(r.mkString(r.exprsReplaced.map(toPrettySQL)), r.dataType)
-    case c: CastBase if 
!c.getTagValue(Cast.USER_SPECIFIED_CAST).getOrElse(false) =>
-      PrettyAttribute(usePrettyExpression(c.child).sql, c.dataType)
+  def usePrettyExpression(
+      e: Expression, existsNonSQLExpression: Boolean = false): Expression = e 
match {
+    case e: NonSQLExpression =>
+      e.withNewChildren(e.children.map(child => usePrettyExpression(child, 
true)))

Review comment:
       Should we handle this in `NonSQLExpression.sql`?




----------------------------------------------------------------
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.

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