Peng-Lei commented on a change in pull request #33033:
URL: https://github.com/apache/spark/pull/33033#discussion_r657568760
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/ColumnExpressionSuite.scala
##########
@@ -2881,4 +2881,41 @@ class ColumnExpressionSuite extends QueryTest with
SharedSparkSession {
}
}
}
+ test("SPARK-35852: add/subtract a interval day to/from a date") {
+ withSQLConf(SQLConf.DATETIME_JAVA8API_ENABLED.key -> "true") {
+ Seq(
+ (LocalDate.of(1, 1, 1), Duration.ofDays(31),
+ LocalDate.of(1, 2, 1),
+ LocalDate.of(0, 12, 1)),
+ (LocalDate.of(1582, 9, 15), Duration.ofDays(30),
+ LocalDate.of(1582, 10, 15),
+ LocalDate.of(1582, 8, 16)),
+ (LocalDate.of(1900, 1, 1), Duration.ofDays(0),
+ LocalDate.of(1900, 1, 1),
+ LocalDate.of(1900, 1, 1)),
+ (LocalDate.of(1970, 1, 1), Duration.ofDays(-1),
+ LocalDate.of(1969, 12, 31),
+ LocalDate.of(1970, 1, 2)),
+ (LocalDate.of(2021, 3, 14), Duration.ofDays(1),
+ LocalDate.of(2021, 3, 15),
+ LocalDate.of(2021, 3, 13)),
+ (LocalDate.of(2020, 12, 31), Duration.ofDays(4 * 30),
+ LocalDate.of(2021, 4, 30),
+ LocalDate.of(2020, 9, 2)),
+ (LocalDate.of(2020, 2, 29), Duration.ofDays(365),
+ LocalDate.of(2021, 2, 28),
+ LocalDate.of(2019, 3, 1)),
+ (LocalDate.of(10000, 1, 1), Duration.ofDays(-2),
+ LocalDate.of(9999, 12, 30),
+ LocalDate.of(10000, 1, 3))
+ ).foreach { case (date, duration, add, sub) =>
Review comment:
> Let's simplify the test, and calculate `add` and `sub`:
>
> ```scala
> val days = duration.toDays
> val add = date.plusDays(days)
> val sub = date.minusDays(days)
> ```
This comment is great for me
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]