SEPURI-SAI-KRISHNA commented on code in PR #60134:
URL: https://github.com/apache/spark/pull/60134#discussion_r4651822068


##########
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:
   I didn't add a flag. The old result was a wrong day count, it only happens 
for dates about 5.8 million years apart, and both behaviors are easy to get 
without one:
   - old result: `unix_date(end) - unix_date(start)` with ANSI off
   - `NULL`: `try_subtract(unix_date(end), unix_date(start))`
   
   The migration note says this, and the test checks both. Happy to add a 
`spark.sql.legacy.*` flag if you'd prefer.
   



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