yaooqinn commented on a change in pull request #28310:
URL: https://github.com/apache/spark/pull/28310#discussion_r420874873



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
##########
@@ -618,6 +618,22 @@ object DateTimeUtils {
     instantToMicros(resultTimestamp.toInstant)
   }
 
+  /**
+   * Add the date and the interval's months and days.
+   * Returns a date value, expressed in days since 1.1.1970.
+   *
+   * @throws DateTimeException if the result exceeds the supported date range
+   * @throws IllegalArgumentException if the interval has `microseconds` part
+   */
+  def dateAddInterval(
+     start: SQLDate,
+     interval: CalendarInterval): SQLDate = {
+    require(interval.microseconds == 0,
+      "Cannot add hours, minutes or seconds, milliseconds, microseconds to a 
date")
+    val ld = 
LocalDate.ofEpochDay(start).plusMonths(interval.months).plusDays(interval.days)

Review comment:
       I will make time for that PR.
   
   FYI, without year-month/day-time specific interval type implementation, the 
operation below looks odd.
   ```sql
   spark-sql> select date '2020-04-30' + interval '1 day 1 month' - interval '1 
day 1 month';
   2020-04-29
   ```




----------------------------------------------------------------
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to