MaxGekk commented on code in PR #45407:
URL: https://github.com/apache/spark/pull/45407#discussion_r1519942137


##########
sql/api/src/main/scala/org/apache/spark/sql/catalyst/util/SparkIntervalUtils.scala:
##########
@@ -131,24 +131,21 @@ trait SparkIntervalUtils {
    */
   def stringToInterval(input: UTF8String): CalendarInterval = {
     import ParseState._
-    def throwIAE(msg: String, e: Exception = null) = {
+    if (input == null) {
       throw new SparkIllegalArgumentException(
-        errorClass = "_LEGACY_ERROR_TEMP_3255",
+        errorClass = "INVALID_INTERVAL_FORMAT.INPUT_IS_NULL",
         messageParameters = Map(
-          "input" -> Option(input).map(_.toString).getOrElse("null"),
-          "msg" -> msg),
-        cause = e)
-    }
-
-    if (input == null) {
-      throwIAE("interval string cannot be null")
+          "input" -> Option(input).map(_.toString).getOrElse("null")))

Review Comment:
   `input` is null for sure here, just place `"null"`



##########
sql/api/src/main/scala/org/apache/spark/sql/catalyst/util/SparkIntervalUtils.scala:
##########
@@ -131,24 +131,21 @@ trait SparkIntervalUtils {
    */
   def stringToInterval(input: UTF8String): CalendarInterval = {
     import ParseState._
-    def throwIAE(msg: String, e: Exception = null) = {
+    if (input == null) {
       throw new SparkIllegalArgumentException(
-        errorClass = "_LEGACY_ERROR_TEMP_3255",
+        errorClass = "INVALID_INTERVAL_FORMAT.INPUT_IS_NULL",
         messageParameters = Map(
-          "input" -> Option(input).map(_.toString).getOrElse("null"),
-          "msg" -> msg),
-        cause = e)
-    }
-
-    if (input == null) {
-      throwIAE("interval string cannot be null")
+          "input" -> Option(input).map(_.toString).getOrElse("null")))
     }
     // scalastyle:off caselocale .toLowerCase
     val s = input.trimAll().toLowerCase
     // scalastyle:on
     val bytes = s.getBytes
     if (bytes.isEmpty) {
-      throwIAE("interval string cannot be empty")
+      throw new SparkIllegalArgumentException(
+        errorClass = "INVALID_INTERVAL_FORMAT.INPUT_IS_EMPTY",
+        messageParameters = Map(
+          "input" -> Option(input).map(_.toString).getOrElse("null")))

Review Comment:
   Can it be `null` here? Seems not.



##########
sql/api/src/main/scala/org/apache/spark/sql/catalyst/util/SparkIntervalUtils.scala:
##########
@@ -183,9 +180,16 @@ trait SparkIntervalUtils {
         case PREFIX =>
           if (s.startsWith(intervalStr)) {
             if (s.numBytes() == intervalStr.numBytes()) {
-              throwIAE("interval string cannot be empty")
+              throw new SparkIllegalArgumentException(
+                errorClass = "INVALID_INTERVAL_FORMAT.INPUT_IS_EMPTY",
+                messageParameters = Map(
+                  "input" -> Option(input).map(_.toString).getOrElse("null")))

Review Comment:
   ditto: can it be `null` here?



-- 
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: reviews-unsubscr...@spark.apache.org

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