sunchao commented on code in PR #40190:
URL: https://github.com/apache/spark/pull/40190#discussion_r1128241190


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/UnwrapCastInBinaryComparisonSuite.scala:
##########
@@ -368,6 +370,61 @@ class UnwrapCastInBinaryComparisonSuite extends PlanTest 
with ExpressionEvalHelp
     assertEquivalent(castInt(f4) < t, trueIfNotNull(f4))
   }
 
+  test("SPARK-42597: Support unwrap date to timestamp type") {

Review Comment:
   could we add some tests in `UnwrapCastInComparisonEndToEndSuite` too?



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/UnwrapCastInBinaryComparison.scala:
##########
@@ -293,6 +299,34 @@ object UnwrapCastInBinaryComparison extends 
Rule[LogicalPlan] {
     }
   }
 
+  /**

Review Comment:
   can we also update the doc for `UnwrapCastInBinaryComparison`? 
   
   > * Currently this only handles cases where:
   >  *   1). `fromType` (of `fromExp`) and `toType` are of numeric types 
(i.e., short, int, float, decimal, etc) or boolean type
   >  *   2). `fromType` can be safely coerced to `toType` without precision 
loss (e.g., short to int, int to long, but not long to int, nor int to boolean)
   
   This is no longer true.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/UnwrapCastInBinaryComparison.scala:
##########
@@ -350,7 +384,7 @@ object UnwrapCastInBinaryComparison extends 
Rule[LogicalPlan] {
       literalType: DataType): Boolean = {
     toType.sameType(literalType) &&
       !fromExp.foldable &&
-      toType.isInstanceOf[NumericType] &&
+      (toType.isInstanceOf[NumericType] || toType.isInstanceOf[DateType]) &&

Review Comment:
   +1



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

Reply via email to