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



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
##########
@@ -385,9 +385,16 @@ object DateTimeUtils {
    * microseconds where microsecond 0 is 1970-01-01 00:00:00Z.
    */
   def instantToMicros(instant: Instant): Long = {
-    val us = Math.multiplyExact(instant.getEpochSecond, MICROS_PER_SECOND)
-    val result = Math.addExact(us, NANOSECONDS.toMicros(instant.getNano))
-    result
+    val secs = instant.getEpochSecond
+    if (secs == Math.floorDiv(Long.MinValue, MICROS_PER_SECOND)) {
+      val us = Math.multiplyExact(secs + 1, MICROS_PER_SECOND)

Review comment:
       I mostly care of the comparison:
   ```scala
   secs == Math.floorDiv(Long.MinValue, MICROS_PER_SECOND)
   ```
   which is performed per every input. Probably, JVM could optimize it but I 
would help to it and introduced a constant.




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