MaxGekk commented on a change in pull request #26256: [SPARK-29605][SQL] 
Optimize string to interval casting
URL: https://github.com/apache/spark/pull/26256#discussion_r339300918
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/IntervalUtils.scala
 ##########
 @@ -119,4 +119,168 @@ object IntervalUtils {
       case _: IllegalArgumentException => null
     }
   }
+
+  private object ParseState extends Enumeration {
+    val PREFIX,
+        BEGIN_VALUE,
+        PARSE_SIGN,
+        POSITIVE_VALUE_TO_LONG,
+        NEGATIVE_VALUE_TO_LONG,
+        BEGIN_UNIT_NAME,
+        UNIT_NAME_SUFFIX,
+        END_UNIT_NAME = Value
+  }
+  private final val intervalStr = UTF8String.fromString("interval")
+  private final val yearStr = UTF8String.fromString("year")
+  private final val monthStr = UTF8String.fromString("month")
+  private final val weekStr = UTF8String.fromString("week")
+  private final val dayStr = UTF8String.fromString("day")
+  private final val hourStr = UTF8String.fromString("hour")
+  private final val minuteStr = UTF8String.fromString("minute")
+  private final val secondStr = UTF8String.fromString("second")
+  private final val millisStr = UTF8String.fromString("millisecond")
+  private final val microsStr = UTF8String.fromString("microsecond")
+
+  def stringToInterval(input: UTF8String): Option[CalendarInterval] = {
 
 Review comment:
   > Why did you use Option here?
   
   The same reason as `stringToDate` and `stringToTimestamp` return 
`Option[...]`. I believe all 3 functions should follow similar convention - 
`None` for errors and `Some[]` for valid values.
   
   Returning `null` instead of `None` looks slightly ugly in Scala but this 
should produce less garbage. Let me think of ...

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to