MaxGekk commented on a change in pull request #26177: [SPARK-29520][SS] Fix 
checks of negative intervals
URL: https://github.com/apache/spark/pull/26177#discussion_r339724025
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/Triggers.scala
 ##########
 @@ -31,7 +31,7 @@ private object Triggers {
 
   def convert(interval: String): Long = {
     val cal = IntervalUtils.fromString(interval)
-    if (cal.months > 0) {
+    if (cal.months != 0) {
 
 Review comment:
   We can change `getDuration()` to:
   ```scala
     def getDuration(
         interval: CalendarInterval,
         targetUnit: TimeUnit,
         daysPerMonth: Option[Int] = Some(31)): Long = {
       val monthsDuration = daysPerMonth
         .map { days =>
           Math.multiplyExact(days * DateTimeUtils.MICROS_PER_DAY, 
interval.months)
         }.getOrElse {
           if (interval.months == 0) {
             0L
           } else {
             throw new IllegalArgumentException(s"Doesn't support month or year 
interval: $interval")
           }
         }
       val result = Math.addExact(interval.microseconds, monthsDuration)
       targetUnit.convert(result, TimeUnit.MICROSECONDS)
     }
   ```
   and call `getDuration(cal, TimeUnit.MILLISECONDS, None)`

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to