dongjoon-hyun commented on code in PR #44480:
URL: https://github.com/apache/spark/pull/44480#discussion_r1436674275


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/UnwrapCastInBinaryComparison.scala:
##########
@@ -144,6 +144,21 @@ object UnwrapCastInBinaryComparison extends 
Rule[LogicalPlan] {
           value != null =>
       Some(unwrapTimestampToDate(be, fromExp, ts, timeZoneId, evalMode))
 
+    // Timestamp/Timestamp_NTZ -> Timestamp_NTZ/Timestamp
+    case be @ BinaryComparison(
+      c @ Cast(fromExp, _, timeZoneId, evalMode), Literal(value, literalType))
+        if AnyTimestampType.acceptsType(fromExp.dataType) &&
+          AnyTimestampType.acceptsType(literalType) && value != null =>
+      // datetime with timezone is tricky, do a round trip to check if the 
rewrite is okay.
+      val newCast = Cast(Literal(value, literalType), fromExp.dataType, 
timeZoneId, evalMode)
+      val roundTrip = Cast(newCast, literalType, timeZoneId, evalMode)

Review Comment:
   Ya, this looks safe.



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