MaxGekk commented on code in PR #60134:
URL: https://github.com/apache/spark/pull/60134#discussion_r4641305816
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala:
##########
@@ -3039,6 +3047,16 @@ private[sql] object QueryExecutionErrors extends
QueryErrorsBase with ExecutionE
summary = "")
}
+ def subtractDatesOverflowError(endDay: Int, startDay: Int):
ArithmeticException = {
Review Comment:
As in #59135: `subtractDatesOverflowError` passes `context = Array.empty`,
and neither `DateDiff` nor `SubtractDates` supplies one, so the error doesn't
show which `datediff` or `d1 - d2` overflowed. Could they extend
`SupportQueryContext` and pass `getContextOrNull()` through
`daysBetween`/`subtractDatesToMicros`?
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala:
##########
@@ -3793,11 +3793,12 @@ case class DateDiff(endDate: Expression, startDate:
Expression)
override def dataType: DataType = IntegerType
override def nullSafeEval(end: Any, start: Any): Any = {
- end.asInstanceOf[Int] - start.asInstanceOf[Int]
+ DateTimeUtils.daysBetween(end.asInstanceOf[Int], start.asInstanceOf[Int])
Review Comment:
With `spark.sql.ansi.enabled=false`, `datediff`/`date_diff` now fail with
`DATETIME_OVERFLOW` instead of wrapping, and there is neither a legacy flag nor
a `try_` form, so a non-ANSI user who hits this can't get NULL back. Could this
have a `spark.sql.legacy.*` flag, or could the migration note say how to get
the old result?
--
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]