SEPURI-SAI-KRISHNA commented on code in PR #59135:
URL: https://github.com/apache/spark/pull/59135#discussion_r4284811138
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/DateExpressionsSuite.scala:
##########
@@ -510,7 +510,20 @@ class DateExpressionsSuite extends SparkFunSuite with
ExpressionEvalHelper {
DateAdd(Literal(Date.valueOf("2016-02-28")), negativeIntLit), -15910)
checkConsistencyBetweenInterpretedAndCodegen(DateAdd, DateType, ByteType)
checkConsistencyBetweenInterpretedAndCodegen(DateAdd, DateType, ShortType)
- checkConsistencyBetweenInterpretedAndCodegen(DateAdd, DateType,
IntegerType)
+ checkConsistencyBetweenInterpretedAndCodegenAllowingException(DateAdd,
DateType, IntegerType)
+ }
+
+ test("SPARK-59859: date_add fails on overflow instead of wrapping around") {
Review Comment:
Added `try_add(date'2021-01-01', 2147483647)`, `try_add(2147483647,
date'2021-01-01')` and `try_subtract(date'1900-01-01', 2147483647)` to
`try_arithmetic.sql`, plus a non-overflowing `try_subtract(date'2021-01-01',
1)` under a new `-- Date - Integer` block. I regenerated the golden files on
JDK 17 and then on JDK 21, so `nonansi/try_arithmetic.sql.out.java21` has the
new cases too. Without the fix, the new cases return the wrapped date
`-5877590-06-22`.
I also fixed the sentence in the PR description: it now says the failure
happens only when the day count overflows an `Int`, and that
`date_add(DATE'9999-12-31', 1)` still returns `+10000-01-01`.
--
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]