sarutak commented on a change in pull request #33031:
URL: https://github.com/apache/spark/pull/33031#discussion_r656584933



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/IntervalUtils.scala
##########
@@ -1023,83 +1023,95 @@ object IntervalUtils {
     var rest = micros
     val from = DayTimeIntervalType.fieldToString(startField).toUpperCase
     val to = DayTimeIntervalType.fieldToString(endField).toUpperCase
+    val prefix = "INTERVAL '"
+    val postfix = s"' ${if (startField == endField) from else s"$from TO $to"}"
+
     if (micros < 0) {
       if (micros == Long.MinValue) {
         // Especial handling of minimum `Long` value because negate op 
overflows `Long`.
         // seconds = 106751991 * (24 * 60 * 60) + 4 * 60 * 60 + 54 = 
9223372036854
         // microseconds = -9223372036854000000L-775808 == Long.MinValue
+        val baseStr = "-106751991 04:00:54.775808000"
         val minIntervalString = style match {
           case ANSI_STYLE =>
-            val baseStr = "-106751991 04:00:54.775808"
-            val fromPos = startField match {
-              case DayTimeIntervalType.DAY => 0
-              case DayTimeIntervalType.HOUR => 11
-              case DayTimeIntervalType.MINUTE => 14
-              case DayTimeIntervalType.SECOND => 17
+            val firstStr = startField match {
+              case DayTimeIntervalType.DAY => "-106751991"
+              case DayTimeIntervalType.HOUR => "-2562047788"
+              case DayTimeIntervalType.MINUTE => "-153722867280"
+              case DayTimeIntervalType.SECOND => "-9223372036854.775808"

Review comment:
       Hmm, `IntervalUnit` has the same name of members and `IntervalUtils` 
imports them. So, importing `DAY`, `SECOND` or any other units and just refers 
them can be cofusable right?
   Instead, how about importing `DayTimeIntervalType` as `DT` and refer the 
units like `DT.DAY`?




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