cloud-fan commented on code in PR #49340: URL: https://github.com/apache/spark/pull/49340#discussion_r1907066565
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercionBase.scala: ########## @@ -326,6 +326,18 @@ abstract class TypeCoercionBase extends TypeCoercionHelper { } } + object CastCoercion extends TypeCoercionRule { + + override val transform: PartialFunction[Expression, Expression] = { + case c @ Cast(child, CharType(_) | VarcharType(_), _, _) if child.resolved => + child.dataType match { + case _: StringType => c + case _ => c.withNewChildren(Seq(Cast(child, StringType))) Review Comment: Why is this necessary? We should support directly cast int to varchar for example. The `Cast` should have a general `castToString` method that supports all string types. -- 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. To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org 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