cloud-fan commented on code in PR #44366:
URL: https://github.com/apache/spark/pull/44366#discussion_r1428507820


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/UnwrapCastInBinaryComparisonSuite.scala:
##########
@@ -406,30 +407,59 @@ class UnwrapCastInBinaryComparisonSuite extends PlanTest 
with ExpressionEvalHelp
   }
 
   test("SPARK-46069: Support unwrap timestamp type to date type") {
-    val tsLit = Literal.create(ts1, TimestampType)
-    val tsNTZLit = Literal.create(ts1, TimestampNTZType)
-    val floorDate = Cast(tsLit, DateType, Some(conf.sessionLocalTimeZone))
-    val floorDateNTZ = Cast(tsNTZLit, DateType, 
Some(conf.sessionLocalTimeZone))
-    val dateAddOne = DateAdd(floorDate, Literal(1, IntegerType))
-    val dateAddOneNTZ = DateAdd(floorDateNTZ, Literal(1, IntegerType))
-    assertEquivalent(
-      castTimestamp(f7) > tsLit || castTimestampNTZ(f7) > tsNTZLit,
-      f7 > floorDate || f7 > floorDateNTZ)
-    assertEquivalent(
-      castTimestamp(f7) >= tsLit || castTimestampNTZ(f7) >= tsNTZLit,
-      f7 >= dateAddOne || f7 >= dateAddOneNTZ)
-    assertEquivalent(
-      castTimestamp(f7) === tsLit || castTimestampNTZ(f7) === tsNTZLit,
-      f7 === floorDate && f7 === dateAddOne || f7 === floorDateNTZ && f7 === 
dateAddOneNTZ)
-    assertEquivalent(
-      castTimestamp(f7) <=> tsLit || castTimestampNTZ(f7) <=> tsNTZLit,
-      FalseLiteral || FalseLiteral)
-    assertEquivalent(
-      castTimestamp(f7) < tsLit || castTimestampNTZ(f7) < tsNTZLit,
-      f7 < dateAddOne || f7 < dateAddOneNTZ)
-    assertEquivalent(
-      castTimestamp(f7) <= tsLit || castTimestampNTZ(f7) <= tsNTZLit,
-      f7 <= floorDate || f7 <= floorDateNTZ)
+    def doTest(tsLit: Literal, tsNTZLit: Literal, isStartOfDay: Boolean): Unit 
= {
+      val floorDate = Cast(tsLit, DateType, Some(conf.sessionLocalTimeZone))
+      val floorDateNTZ = Cast(tsNTZLit, DateType, 
Some(conf.sessionLocalTimeZone))
+      val dateAddOne = DateAdd(floorDate, Literal(1, IntegerType))
+      val dateAddOneNTZ = DateAdd(floorDateNTZ, Literal(1, IntegerType))
+      assertEquivalent(
+        castTimestamp(f7) > tsLit || castTimestampNTZ(f7) > tsNTZLit,
+        f7 > floorDate || f7 > floorDateNTZ)
+      if (isStartOfDay) {
+        assertEquivalent(
+          castTimestamp(f7) >= tsLit || castTimestampNTZ(f7) >= tsNTZLit,

Review Comment:
   is there any difference between timestamp ltz and ntz? if not we can 
simplify the test even more
   ```
   def doTest(ts: Literal, isStartDay: Boolean) {
     val floorDate = ...
     val dateAddOne = ...
     ....
   }
   ```
   then the caller side
   ```
   doTest(ltzLit, ...)
   doTest(ntzLit, ...)
   ```



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