You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/06/28 13:11:47 UTC

[GitHub] [spark] maropu commented on a change in pull request #32850: [SPARK-34920][CORE][SQL] Add error classes with SQLSTATE

maropu commented on a change in pull request #32850:
URL: https://github.com/apache/spark/pull/32850#discussion_r659770974



##########
File path: core/src/main/scala/org/apache/spark/SparkException.scala
##########
@@ -50,3 +65,16 @@ private[spark] case class ExecutorDeadException(message: String)
 private[spark] class SparkUpgradeException(version: String, message: String, cause: Throwable)
   extends RuntimeException("You may get a different result due to the upgrading of Spark" +
     s" $version: $message", cause)
+
+/**
+ * Arithmetic exception thrown from Spark with an error class.
+ */
+private[spark] class SparkArithmeticException(

Review comment:
       `private[spark]`? Could we make the new standardized error classes public to 3rd-party develoeprs?

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -0,0 +1,22 @@
+{
+  "DIVIDE_BY_ZERO" : {
+    "sqlState" : "22012",
+    "message" : [ "divide by zero" ]
+  },

Review comment:
       Just a comment; it would be nice to automatically generate a user's doc page (just like the PostgreSQL one) from this error state definition file.

##########
File path: core/src/main/resources/error/README.md
##########
@@ -0,0 +1,79 @@
+# Guidelines
+
+To throw a standardized exception, developers should use an error class and message parameters
+rather than an arbitrary error message.
+
+## Usage
+
+To throw an exception, do the following.
+
+1. Check if an appropriate error class already exists in `error-class.json`.

Review comment:
       Why do we need to load these error states from a json file instead of defining them statically in a companion object?




-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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