MaxGekk commented on a change in pull request #31799:
URL: https://github.com/apache/spark/pull/31799#discussion_r592107485



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/IntervalUtils.scala
##########
@@ -779,9 +782,14 @@ object IntervalUtils {
    * @throws ArithmeticException If numeric overflow occurs
    */
   def durationToMicros(duration: Duration): Long = {
-    val us = Math.multiplyExact(duration.getSeconds, MICROS_PER_SECOND)
-    val result = Math.addExact(us, duration.getNano / NANOS_PER_MICROS)
-    result
+    val seconds = duration.getSeconds
+    if (seconds == minDurationSeconds) {
+      val us = (minDurationSeconds + 1) * MICROS_PER_SECOND
+      Math.addExact(us, (duration.getNano - NANOS_PER_SECOND) / 
NANOS_PER_MICROS)

Review comment:
       According to Java doc for `Duration.getNano`:
   ```java
        * @return the nanoseconds within the second part of the length of the 
duration, from 0 to 999,999,999
        */
       public int getNano() {
           return nanos;
       }
   ```




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



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

Reply via email to