itholic commented on code in PR #39128:
URL: https://github.com/apache/spark/pull/39128#discussion_r1052123143


##########
python/pyspark/errors/error_classes.py:
##########
@@ -0,0 +1,30 @@
+#
+# 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.
+#
+
+
+ERROR_CLASSES = {
+    "COLUMN_IN_LIST": lambda func_name: f"{func_name} does not allow a column 
in a list",
+    "HIGHER_ORDER_FUNCTION_SHOULD_RETURN_COLUMN": lambda func_name, 
return_type: f"Function '{func_name}' should return Column, got {return_type}",
+    "NOT_A_COLUMN": lambda arg_name, arg_type: f"Argument '{arg_name}' should 
be a column, got '{arg_type}'.",
+    "NOT_A_STRING": lambda arg_name, arg_type: f"Argument '{arg_name}' should 
be a string, got '{arg_type}'.",
+    "NOT_COLUMN_OR_INTEGER": lambda arg_name, arg_type: f"Argument 
'{arg_name}' should be a column or integer, got '{arg_type}'.",
+    "NOT_COLUMN_OR_INTEGER_OR_STRING": lambda arg_name, arg_type: f"Argument 
'{arg_name}' should be a column or integer or string, got '{arg_type}'.",
+    "NOT_COLUMN_OR_STRING": lambda arg_name, arg_type: f"Argument '{arg_name}' 
should be a column or string, got '{arg_type}'.",

Review Comment:
   Such errors of similar categories may need to be grouped together and 
managed as a sub-error class.
   
   For example, `NOT_A_COLUMN `, `NOT_A_STRING `, `NOT_COLUMN_OR_INTEGER `, 
`NOT_COLUMN_OR_INTEGER_OR_STRING ` and `NOT_COLUMN_OR_STRING ` could be defined 
as `INVALID_TYPE_FOR_ARGUMENT` with one parent error class.
   
   In the current PR, I want to focus on the discussion of the overall idea and 
structure, so let me follow-up for sub-error classes by adding more error 
classes later if needed.



##########
python/pyspark/errors/error_classes.py:
##########
@@ -0,0 +1,30 @@
+#
+# 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.
+#
+
+
+ERROR_CLASSES = {
+    "COLUMN_IN_LIST": lambda func_name: f"{func_name} does not allow a column 
in a list",
+    "HIGHER_ORDER_FUNCTION_SHOULD_RETURN_COLUMN": lambda func_name, 
return_type: f"Function '{func_name}' should return Column, got {return_type}",
+    "NOT_A_COLUMN": lambda arg_name, arg_type: f"Argument '{arg_name}' should 
be a column, got '{arg_type}'.",
+    "NOT_A_STRING": lambda arg_name, arg_type: f"Argument '{arg_name}' should 
be a string, got '{arg_type}'.",
+    "NOT_COLUMN_OR_INTEGER": lambda arg_name, arg_type: f"Argument 
'{arg_name}' should be a column or integer, got '{arg_type}'.",
+    "NOT_COLUMN_OR_INTEGER_OR_STRING": lambda arg_name, arg_type: f"Argument 
'{arg_name}' should be a column or integer or string, got '{arg_type}'.",
+    "NOT_COLUMN_OR_STRING": lambda arg_name, arg_type: f"Argument '{arg_name}' 
should be a column or string, got '{arg_type}'.",

Review Comment:
   Such errors of similar categories may need to be grouped together and 
managed as a sub-error class.
   
   For example, `NOT_A_COLUMN `, `NOT_A_STRING `, `NOT_COLUMN_OR_INTEGER `, 
`NOT_COLUMN_OR_INTEGER_OR_STRING ` and `NOT_COLUMN_OR_STRING ` could be defined 
as `INVALID_TYPE_FOR_ARGUMENT` with one parent error class.
   
   In the current PR, I want to focus on the quick discussion of the overall 
idea and structure, so let me follow-up for sub-error classes by adding more 
error classes later if needed.



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