cloud-fan commented on a change in pull request #31034:
URL: https://github.com/apache/spark/pull/31034#discussion_r552429275



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
##########
@@ -1733,12 +1739,19 @@ abstract class CastBase extends UnaryExpression with 
TimeZoneAwareExpression wit
       """
   }
 
-  override def sql: String = dataType match {
-    // HiveQL doesn't allow casting to complex types. For logical plans 
translated from HiveQL, this
-    // type of casting can only be introduced by the analyzer, and can be 
omitted when converting
-    // back to SQL query string.
-    case _: ArrayType | _: MapType | _: StructType => child.sql
-    case _ => s"CAST(${child.sql} AS ${dataType.sql})"
+  override def sql: String = {

Review comment:
       Let's not change the `sql` method.
   
   `ResolveAlias` calls `toPrettySQL` to generate the alias name, and we should 
strip auto-generated alias in `toPrettySQL`.




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