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



##########
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:
       on the other hand, I think it's safer to not remove nullability when 
comparing query plans. Maybe two plans are truly different because the 
nullability is different and the data is also different.




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