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



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/Column.scala
##########
@@ -1181,7 +1181,9 @@ class Column(val expr: Expression) extends Logging {
    * @group expr_ops
    * @since 1.3.0
    */
-  def cast(to: DataType): Column = withExpr { Cast(expr, to) }
+  def cast(to: DataType): Column = withExpr {
+    Cast(expr, CharVarcharUtils.replaceCharVarcharWithString(to))
+  }

Review comment:
       If you do `col.cast("char(5)")` before this PR, Spark already silently 
treats it as cast to string type. I don't want to change this behavior here. We 
can make it better later, by failing explicitly and saying that cast to char 
type is not supported.




----------------------------------------------------------------
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to