shardulm94 commented on a change in pull request #35332:
URL: https://github.com/apache/spark/pull/35332#discussion_r794293190



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
##########
@@ -310,13 +310,16 @@ abstract class CastBase extends UnaryExpression with 
TimeZoneAwareExpression wit
 
   protected def ansiEnabled: Boolean
 
+  protected def withDataType(dataType: DataType): CastBase
+
   // When this cast involves TimeZone, it's only resolved if the timeZoneId is 
set;
   // Otherwise behave like Expression.resolved.
   override lazy val resolved: Boolean =
     childrenResolved && checkInputDataTypes().isSuccess && (!needsTimeZone || 
timeZoneId.isDefined)
 
   override lazy val preCanonicalized: Expression = {
     val basic = 
withNewChildren(Seq(child.preCanonicalized)).asInstanceOf[CastBase]
+      .withDataType(dataType.asNullable)

Review comment:
       I agree. I think its probably more deviation in behavior, but safer 
overall. I will update this PR soon.




-- 
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: [email protected]

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