cloud-fan commented on a change in pull request #26995: [SPARK-30341][SQL] 
Overflow check for interval arithmetic operations
URL: https://github.com/apache/spark/pull/26995#discussion_r361660797
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/IntervalUtils.scala
 ##########
 @@ -413,6 +415,49 @@ object IntervalUtils {
     new CalendarInterval(truncatedMonths, truncatedDays, micros.round)
   }
 
+  /**
+   * Makes an interval from months, days and micros with the fractional part by
+   * adding the month fraction to days and the days fraction to micros.
+   */
+  private def safeFromDoubles(
+      monthsWithFraction: Double,
+      daysWithFraction: Double,
+      microsWithFraction: Double): CalendarInterval = {
+    val monthInLong = monthsWithFraction.toLong
+    val truncatedMonths = if (monthInLong > Int.MaxValue) {
 
 Review comment:
   We add the overflow flag so that we can avoid breaking backward 
compatibility. We don't have this concern for interval multiple.
   
   For the overflow behavior, I think it's caused by `Double.toLong`. Is there 
an exact version of it? if not we may need to check `double > Long.Max` first.

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


With regards,
Apache Git Services

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

Reply via email to