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


##########
common/utils/src/main/resources/error/error-classes.json:
##########
@@ -3213,6 +3225,12 @@
     ],
     "sqlState" : "0A000"
   },
+  "UNSUPPORTED_DATA_TYPE_FOR_SIZE_FUNCTION" : {

Review Comment:
   I think we can remove this error class because:
   ```scala
     override def inputTypes: Seq[AbstractDataType] = 
Seq(TypeCollection(ArrayType, MapType))
   ```
   and the case must be unreachable:
   ```scala
         case other => throw 
QueryExecutionErrors.unsupportedOperandTypeForSizeFunctionError(other)
   ```
   @dengziming Please, replace it by an internal error.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala:
##########
@@ -1370,21 +1370,21 @@ private[sql] object QueryExecutionErrors extends 
QueryErrorsBase with ExecutionE
   def unsupportedOperandTypeForSizeFunctionError(
       dataType: DataType): SparkUnsupportedOperationException = {
     new SparkUnsupportedOperationException(
-      errorClass = "_LEGACY_ERROR_TEMP_2156",
+      errorClass = "UNSUPPORTED_DATA_TYPE_FOR_SIZE_FUNCTION",
       messageParameters = Map(
         "dataType" -> dataType.getClass.getCanonicalName))
   }
 
   def unexpectedValueForStartInFunctionError(prettyName: String): 
SparkRuntimeException = {
     new SparkRuntimeException(
-      errorClass = "_LEGACY_ERROR_TEMP_2157",
+      errorClass = "UNEXPECTED_VALUE_FOR_START_IN_SLICE_FUNCTION",
       messageParameters = Map(
         "prettyName" -> prettyName))

Review Comment:
   Is the pretty name a id, if so, please, wrap it by `toSQLId`



##########
common/utils/src/main/resources/error/error-classes.json:
##########
@@ -3029,6 +3029,18 @@
     ],
     "sqlState" : "42846"
   },
+  "UNEXPECTED_VALUE_FOR_LENGTH_IN_SLICE_FUNCTION" : {

Review Comment:
   Could you create a sub-class of the error class `INVALID_PARAMETER_VALUE`, 
and follow formats of other sub-classes like:
   ```
   expects ..., but got ... .
   ```



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala:
##########
@@ -1370,21 +1370,21 @@ private[sql] object QueryExecutionErrors extends 
QueryErrorsBase with ExecutionE
   def unsupportedOperandTypeForSizeFunctionError(
       dataType: DataType): SparkUnsupportedOperationException = {
     new SparkUnsupportedOperationException(
-      errorClass = "_LEGACY_ERROR_TEMP_2156",
+      errorClass = "UNSUPPORTED_DATA_TYPE_FOR_SIZE_FUNCTION",
       messageParameters = Map(
         "dataType" -> dataType.getClass.getCanonicalName))
   }
 
   def unexpectedValueForStartInFunctionError(prettyName: String): 
SparkRuntimeException = {
     new SparkRuntimeException(
-      errorClass = "_LEGACY_ERROR_TEMP_2157",
+      errorClass = "UNEXPECTED_VALUE_FOR_START_IN_SLICE_FUNCTION",
       messageParameters = Map(
         "prettyName" -> prettyName))
   }
 
   def unexpectedValueForLengthInFunctionError(prettyName: String): 
SparkRuntimeException = {
     new SparkRuntimeException(
-      errorClass = "_LEGACY_ERROR_TEMP_2158",
+      errorClass = "UNEXPECTED_VALUE_FOR_LENGTH_IN_SLICE_FUNCTION",
       messageParameters = Map(
         "prettyName" -> prettyName))

Review Comment:
   Use `toSQLId`



##########
sql/core/src/test/scala/org/apache/spark/sql/CollectionFunctionsSuite.scala:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql
+
+import org.apache.spark.{SparkFunSuite, SparkRuntimeException}
+import org.apache.spark.sql.test.SharedSparkSession
+
+class CollectionFunctionsSuite extends SparkFunSuite with SharedSparkSession {

Review Comment:
   Move the tests to `QueryExecutionErrorsSuite`



##########
common/utils/src/main/resources/error/error-classes.json:
##########
@@ -3029,6 +3029,18 @@
     ],
     "sqlState" : "42846"
   },
+  "UNEXPECTED_VALUE_FOR_LENGTH_IN_SLICE_FUNCTION" : {
+    "message" : [
+      "Unexpected value for length in function <prettyName>: length must be 
greater than or equal to 0."
+    ],
+    "sqlState" : "22003"
+  },
+  "UNEXPECTED_VALUE_FOR_START_IN_SLICE_FUNCTION" : {

Review Comment:
   Please, create a sub-class in `INVALID_PARAMETER_VALUE`.



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