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



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/IntervalUtils.scala
##########
@@ -594,23 +596,29 @@ object IntervalUtils {
       s"$fallbackNotice")
     var micros: Long = 0L
     var days: Int = 0
+    val sign = if (m.group("sign") != null && m.group("sign") == "-") -1 else 1
     unitsRange(to, from).foreach {
       case unit @ DAY =>
-        days = toLongWithRange(unit, m.group(unit.toString), 0, 
Int.MaxValue).toInt
+        days = sign * toLongWithRange(unit, m.group(unit.toString), 0, 
Int.MaxValue).toInt
       case unit @ HOUR =>
-        val parsed = toLongWithRange(unit, m.group(unit.toString), 0, 23)
-        micros = Math.addExact(micros, parsed * MICROS_PER_HOUR)
+        val parsed = toLongWithRange(unit, m.group(unit.toString), 0,
+          if (from == HOUR) 2562047788L else 23)

Review comment:
       Let's add constants for the magic number 2562047788L and for 
153722867280L. It might be not clear what they mean for unfamiliar devs.




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

To unsubscribe, e-mail: [email protected]

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