wankunde commented on code in PR #44366:
URL: https://github.com/apache/spark/pull/44366#discussion_r1429167102
##########
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:
Timestamp and TimestampNTZ are different.
We can create a TimestampNTZ from `LocalDateTime.of(2023, 12, 13, 0, 0, 0,
0)` where `isStartOfDay` is true, but I did not find a way to create a
Timestamp from LocalDateTime or ZonedDateTime where the `isStartOfDay` is true.
--
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]