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


##########
sql/api/src/main/scala/org/apache/spark/sql/types/StructType.scala:
##########
@@ -316,10 +316,10 @@ case class StructType(fields: Array[StructField]) extends 
DataType with Seq[Stru
   def fieldIndex(name: String): Int = {
     nameToIndex.getOrElse(name,
       throw new SparkIllegalArgumentException(
-        errorClass = "_LEGACY_ERROR_TEMP_3252",
+        errorClass = "FIELD_NOT_FOUND",
         messageParameters = immutable.Map(
-          "name" -> name,
-          "fieldNames" -> fieldNames.mkString(", "))))
+          "fieldName" -> name,

Review Comment:
   ditto



##########
common/utils/src/main/resources/error/error-classes.json:
##########
@@ -1823,6 +1830,24 @@
     },
     "sqlState" : "HY109"
   },
+  "INVALID_DATETIME_PATTERN" : {
+    "message" : [
+      "Unrecognized datetime pattern: <pattern>. Please provide correct 
datetime pattern."

Review Comment:
   ```suggestion
         "Unrecognized datetime pattern: <pattern>."
   ```
   The second sentence is useless, I think. Let's leave suggestions to 
sub-classes.



##########
sql/api/src/main/scala/org/apache/spark/sql/catalyst/util/SparkIntervalUtils.scala:
##########
@@ -229,13 +237,21 @@ trait SparkIntervalUtils {
               try {
                 currentValue = Math.addExact(Math.multiplyExact(10, 
currentValue), (b - '0'))
               } catch {
-                case e: ArithmeticException => throwIAE(e.getMessage, e)
+                case e: ArithmeticException => throw new 
SparkIllegalArgumentException(
+                  errorClass = "INVALID_INTERVAL_FORMAT.ARITHMETIC_EXCEPTION",

Review Comment:
   Are you sure that the error is related to a format but not to parsed value?



##########
sql/api/src/main/scala/org/apache/spark/sql/types/StructType.scala:
##########
@@ -283,10 +283,10 @@ case class StructType(fields: Array[StructField]) extends 
DataType with Seq[Stru
   def apply(name: String): StructField = {
     nameToField.getOrElse(name,
       throw new SparkIllegalArgumentException(
-        errorClass = "_LEGACY_ERROR_TEMP_3254",
+        errorClass = "FIELD_NOT_FOUND",
         messageParameters = immutable.Map(
-          "name" -> name,
-          "fieldNames" -> fieldNames.mkString(", "))))
+          "fieldName" -> name,

Review Comment:
   Field names are identifiers, I guess. If so, please, quote them using 
`toSQLId`



##########
common/utils/src/main/resources/error/error-classes.json:
##########
@@ -2060,6 +2085,74 @@
     },
     "sqlState" : "42000"
   },
+  "INVALID_INTERVAL_FORMAT" : {
+    "message" : [
+      "Error parsing '<input>' to interval. Please ensure that the value 
provided is in a valid format for defining an interval. You can reference the 
documentation for the correct format."
+    ],
+    "subClass" : {
+      "ARITHMETIC_EXCEPTION" : {
+        "message" : [
+          "Uncaught arithmetic exception: <e>."

Review Comment:
   Could you avoid the arbitrary text in `<e>`. In the future, we will 
translate error messages in different languages. We don't need uncontrolled 
inlining of some English text.



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