karenfeng commented on a change in pull request #33878:
URL: https://github.com/apache/spark/pull/33878#discussion_r710580234



##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -21,6 +67,15 @@
   "FAILED_SET_ORIGINAL_PERMISSION_BACK" : {
     "message" : [ "Failed to set original permission %s back to the created 
path: %s. Exception: %s" ]
   },
+  "FAILED_TO_CALL_PUBLIC_NO_ARG_CONSTRUCTOR_FOR_CONSTRUCTOR" : {
+    "message" : [ "Failed to call public no-arg constructor for catalog '%s': 
%s" ]
+  },
+  "FAILED_TO_FIND_PUBLIC_NO_ARG_CONSTRUCTOR_FOR_CONSTRUCTOR" : {

Review comment:
         `FAILED_TO_FIND_PUBLIC_NO_ARG_CONSTRUCTOR_FOR_CONSTRUCTOR` -> 
`FAILED_TO_FIND_PUBLIC_NO_ARG_CONSTRUCTOR_FOR_CATALOG`

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -77,6 +144,9 @@
     "message" : [ "PARTITION clause cannot contain a non-partition column 
name: %s" ],
     "sqlState" : "42000"
   },
+  "NO_SUCH_ELEMENT_EXCEPTION" : {

Review comment:
       We should:
   - Remove the word `EXCEPTION` from the error class.
   - Update the error message to better reflect what type of error this is, 
maybe with `No such element %s`?

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -1,8 +1,54 @@
 {
+  "ADD_FILES_WITH_ABSOLUTE_PATH_UNSUPPORTED" : {
+    "message" : [ "%s does not support adding files with an absolute path" ],
+    "sqlState" : "0A000"
+  },
   "AMBIGUOUS_FIELD_NAME" : {
     "message" : [ "Field name %s is ambiguous and has %s matching fields in 
the struct." ],
     "sqlState" : "42000"
   },
+  "BATCH_METADATA_FILE_NOT_FOUND" : {
+    "message" : [ "Unable to find batch %s" ]
+  },
+  "CANNOT_CLONE_OR_COPY_READ_ONLY_SQL_CONF" : {
+    "message" : [ "Cannot clone/copy ReadOnlySQLConf." ],
+    "sqlState" : "42000"
+  },
+  "CANNOT_EXECUTE_STREAMING_RELATION_EXEC" : {
+    "message" : [ "StreamingRelationExec cannot be executed" ],
+    "sqlState" : "42000"
+  },
+  "CANNOT_GET_EVENT_TIME_WATERMARK" : {
+    "message" : [ "Cannot get event time watermark timestamp without setting 
watermark before [map|flatMap]GroupsWithState" ],
+    "sqlState" : "42000"
+  },
+  "CANNOT_GET_SQL_CONF_IN_SCHEDULER_EVENT_LOOP_THREAD" : {
+    "message" : [ "Cannot get SQLConf inside scheduler event loop thread." ]
+  },
+  "CANNOT_INSTANTIATE_ABSTRACT_CATALOG_PLUGIN_CLASS" : {
+    "message" : [ "Cannot instantiate abstract catalog plugin class for 
catalog '%s': %s" ],
+    "sqlState" : "42000"
+  },
+  "CANNOT_MUTATE_READ_ONLY_SQL_CONF" : {
+    "message" : [ "Cannot mutate ReadOnlySQLConf." ],
+    "sqlState" : "42000"
+  },
+  "CANNOT_SET_TIMEOUT_TIMESTAMP" : {
+    "message" : [ "Cannot set timeout timestamp without enabling event time 
timeout in [map|flatMapGroupsWithState" ],

Review comment:
       `[map|flatMap` -> `[map|flatMap]`

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -21,6 +67,15 @@
   "FAILED_SET_ORIGINAL_PERMISSION_BACK" : {
     "message" : [ "Failed to set original permission %s back to the created 
path: %s. Exception: %s" ]
   },
+  "FAILED_TO_CALL_PUBLIC_NO_ARG_CONSTRUCTOR_FOR_CONSTRUCTOR" : {

Review comment:
       `FAILED_TO_CALL_PUBLIC_NO_ARG_CONSTRUCTOR_FOR_CONSTRUCTOR` -> 
`FAILED_TO_CALL_PUBLIC_NO_ARG_CONSTRUCTOR_FOR_CATALOG`

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala
##########
@@ -1407,105 +1407,139 @@ object QueryExecutionErrors {
   }
 
   def cannotSetTimeoutTimestampError(): Throwable = {
-    new UnsupportedOperationException(
-      "Cannot set timeout timestamp without enabling event time timeout in " +
-        "[map|flatMapGroupsWithState")
+    new SparkUnsupportedOperationException(
+      errorClass = "CANNOT_GET_EVENT_TIME_WATERMARK",
+      messageParameters = Array.empty
+    )
   }
 
   def batchMetadataFileNotFoundError(batchMetadataFile: Path): Throwable = {
-    new FileNotFoundException(s"Unable to find batch $batchMetadataFile")
+    new SparkFileNotFoundException(
+      errorClass = "BATCH_METADATA_FILE_NOT_FOUND",
+      messageParameters = Array(batchMetadataFile.toString)
+    )
   }
 
   def multiStreamingQueriesUsingPathConcurrentlyError(
       path: String, e: FileAlreadyExistsException): Throwable = {
-    new ConcurrentModificationException(
-      s"Multiple streaming queries are concurrently using $path", e)
+    new SparkConcurrentModificationException(
+      errorClass = "MULTI_STREAMING_QUERIES_USING_PATH_CONCURRENTLY",
+      messageParameters = Array(path), e)
   }
 
   def addFilesWithAbsolutePathUnsupportedError(commitProtocol: String): 
Throwable = {
-    new UnsupportedOperationException(
-      s"$commitProtocol does not support adding files with an absolute path")
+    new SparkUnsupportedOperationException(
+      errorClass = "ADD_FILES_WITH_ABSOLUTE_PATH_UNSUPPORTED",
+      messageParameters = Array(commitProtocol))
   }
 
   def microBatchUnsupportedByDataSourceError(srcName: String): Throwable = {
-    new UnsupportedOperationException(
-      s"Data source $srcName does not support microbatch processing.")
+    new SparkUnsupportedOperationException(
+      errorClass = "MICRO_BATCH_UNSUPPORTED_BY_DATA_SOURCE",
+      messageParameters = Array(srcName))
   }
 
   def cannotExecuteStreamingRelationExecError(): Throwable = {
-    new UnsupportedOperationException("StreamingRelationExec cannot be 
executed")
+    new SparkUnsupportedOperationException(
+      errorClass = "CANNOT_EXECUTE_STREAMING_RELATION_EXEC",
+      messageParameters = Array.empty
+    )
   }
 
   def invalidStreamingOutputModeError(outputMode: Option[OutputMode]): 
Throwable = {
-    new UnsupportedOperationException(s"Invalid output mode: $outputMode")
+    new SparkUnsupportedOperationException(
+      errorClass = "INVALID_STREAMING_OUTPUT_MODE",
+      messageParameters = Array(outputMode.toString)
+    )
   }
 
   def catalogPluginClassNotFoundError(name: String): Throwable = {
-    new CatalogNotFoundException(
-      s"Catalog '$name' plugin class not found: spark.sql.catalog.$name is not 
defined")
+    new SparkCatalogNotFoundException(
+      errorClass = "CATALOG_PLUGIN_CLASS_NOT_FOUND",
+      messageParameters = Array(name, name))
   }
 
   def catalogPluginClassNotImplementedError(name: String, pluginClassName: 
String): Throwable = {
     new SparkException(
-      s"Plugin class for catalog '$name' does not implement CatalogPlugin: 
$pluginClassName")
+      errorClass = "CATALOG_PLUGIN_CLASS_NOT_IMPLEMENTED",
+      messageParameters = Array(name, pluginClassName), null)
   }
 
   def catalogPluginClassNotFoundForCatalogError(
       name: String,
       pluginClassName: String): Throwable = {
-    new SparkException(s"Cannot find catalog plugin class for catalog '$name': 
$pluginClassName")
+    new SparkException(
+      errorClass = "CATALOG_PLUGIN_CLASS_NOT_FOUND_FOR_CATALOG",
+      messageParameters = Array(name, pluginClassName), null)
   }
 
   def catalogFailToFindPublicNoArgConstructorError(
       name: String,
       pluginClassName: String,
       e: Exception): Throwable = {
     new SparkException(
-      s"Failed to find public no-arg constructor for catalog '$name': 
$pluginClassName)", e)
+      errorClass = "FAILED_TO_FIND_PUBLIC_NO_ARG_CONSTRUCTOR_FOR_CONSTRUCTOR",
+      messageParameters = Array(name, pluginClassName), e)
   }
 
+
   def catalogFailToCallPublicNoArgConstructorError(
       name: String,
       pluginClassName: String,
       e: Exception): Throwable = {
     new SparkException(
-      s"Failed to call public no-arg constructor for catalog '$name': 
$pluginClassName)", e)
+      errorClass = "FAILED_TO_CALL_PUBLIC_NO_ARG_CONSTRUCTOR_FOR_CONSTRUCTOR",
+      messageParameters = Array(name, pluginClassName), e)
   }
 
   def cannotInstantiateAbstractCatalogPluginClassError(
       name: String,
       pluginClassName: String,
       e: Exception): Throwable = {
-    new SparkException("Cannot instantiate abstract catalog plugin class for " 
+
-      s"catalog '$name': $pluginClassName", e.getCause)
+      new SparkException(
+        errorClass = "CANNOT_INSTANTIATE_ABSTRACT_CATALOG_PLUGIN_CLASS",
+        messageParameters = Array(name, pluginClassName), e.getCause)
   }
 
   def failedToInstantiateConstructorForCatalogError(
       name: String,
       pluginClassName: String,
       e: Exception): Throwable = {
-    new SparkException("Failed during instantiating constructor for catalog " +
-      s"'$name': $pluginClassName", e.getCause)
+    new SparkException(
+      errorClass = "FAILED_TO_INSTANTIATE_CONSTRUCTOR_FOR_CATALOG",
+      messageParameters = Array(name, pluginClassName), e.getCause)
   }
 
   def noSuchElementExceptionError(): Throwable = {
-    new NoSuchElementException
+    new SparkNoSuchElementException(
+      errorClass = "NO_SUCH_ELEMENT_EXCEPTION",
+      messageParameters = Array.empty
+    )
   }
 
   def noSuchElementExceptionError(key: String): Throwable = {
     new NoSuchElementException(key)

Review comment:
       This should share an error class with the exception above.

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala
##########
@@ -1407,105 +1407,139 @@ object QueryExecutionErrors {
   }
 
   def cannotSetTimeoutTimestampError(): Throwable = {
-    new UnsupportedOperationException(
-      "Cannot set timeout timestamp without enabling event time timeout in " +
-        "[map|flatMapGroupsWithState")
+    new SparkUnsupportedOperationException(
+      errorClass = "CANNOT_GET_EVENT_TIME_WATERMARK",

Review comment:
       Is this the right error class?

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -1,8 +1,54 @@
 {
+  "ADD_FILES_WITH_ABSOLUTE_PATH_UNSUPPORTED" : {
+    "message" : [ "%s does not support adding files with an absolute path" ],
+    "sqlState" : "0A000"
+  },
   "AMBIGUOUS_FIELD_NAME" : {
     "message" : [ "Field name %s is ambiguous and has %s matching fields in 
the struct." ],
     "sqlState" : "42000"
   },
+  "BATCH_METADATA_FILE_NOT_FOUND" : {
+    "message" : [ "Unable to find batch %s" ]
+  },
+  "CANNOT_CLONE_OR_COPY_READ_ONLY_SQL_CONF" : {
+    "message" : [ "Cannot clone/copy ReadOnlySQLConf." ],
+    "sqlState" : "42000"

Review comment:
       `0A000` may be a better fit here

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -1,8 +1,54 @@
 {
+  "ADD_FILES_WITH_ABSOLUTE_PATH_UNSUPPORTED" : {
+    "message" : [ "%s does not support adding files with an absolute path" ],
+    "sqlState" : "0A000"
+  },
   "AMBIGUOUS_FIELD_NAME" : {
     "message" : [ "Field name %s is ambiguous and has %s matching fields in 
the struct." ],
     "sqlState" : "42000"
   },
+  "BATCH_METADATA_FILE_NOT_FOUND" : {
+    "message" : [ "Unable to find batch %s" ]
+  },
+  "CANNOT_CLONE_OR_COPY_READ_ONLY_SQL_CONF" : {
+    "message" : [ "Cannot clone/copy ReadOnlySQLConf." ],
+    "sqlState" : "42000"
+  },
+  "CANNOT_EXECUTE_STREAMING_RELATION_EXEC" : {
+    "message" : [ "StreamingRelationExec cannot be executed" ],
+    "sqlState" : "42000"
+  },
+  "CANNOT_GET_EVENT_TIME_WATERMARK" : {
+    "message" : [ "Cannot get event time watermark timestamp without setting 
watermark before [map|flatMap]GroupsWithState" ],
+    "sqlState" : "42000"
+  },
+  "CANNOT_GET_SQL_CONF_IN_SCHEDULER_EVENT_LOOP_THREAD" : {
+    "message" : [ "Cannot get SQLConf inside scheduler event loop thread." ]
+  },
+  "CANNOT_INSTANTIATE_ABSTRACT_CATALOG_PLUGIN_CLASS" : {
+    "message" : [ "Cannot instantiate abstract catalog plugin class for 
catalog '%s': %s" ],
+    "sqlState" : "42000"
+  },
+  "CANNOT_MUTATE_READ_ONLY_SQL_CONF" : {
+    "message" : [ "Cannot mutate ReadOnlySQLConf." ],
+    "sqlState" : "42000"

Review comment:
       `0A000` feels like a better fit for this

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -1,8 +1,54 @@
 {
+  "ADD_FILES_WITH_ABSOLUTE_PATH_UNSUPPORTED" : {
+    "message" : [ "%s does not support adding files with an absolute path" ],
+    "sqlState" : "0A000"
+  },
   "AMBIGUOUS_FIELD_NAME" : {
     "message" : [ "Field name %s is ambiguous and has %s matching fields in 
the struct." ],
     "sqlState" : "42000"
   },
+  "BATCH_METADATA_FILE_NOT_FOUND" : {
+    "message" : [ "Unable to find batch %s" ]
+  },
+  "CANNOT_CLONE_OR_COPY_READ_ONLY_SQL_CONF" : {
+    "message" : [ "Cannot clone/copy ReadOnlySQLConf." ],
+    "sqlState" : "42000"
+  },
+  "CANNOT_EXECUTE_STREAMING_RELATION_EXEC" : {
+    "message" : [ "StreamingRelationExec cannot be executed" ],
+    "sqlState" : "42000"
+  },
+  "CANNOT_GET_EVENT_TIME_WATERMARK" : {
+    "message" : [ "Cannot get event time watermark timestamp without setting 
watermark before [map|flatMap]GroupsWithState" ],
+    "sqlState" : "42000"
+  },
+  "CANNOT_GET_SQL_CONF_IN_SCHEDULER_EVENT_LOOP_THREAD" : {
+    "message" : [ "Cannot get SQLConf inside scheduler event loop thread." ]
+  },
+  "CANNOT_INSTANTIATE_ABSTRACT_CATALOG_PLUGIN_CLASS" : {
+    "message" : [ "Cannot instantiate abstract catalog plugin class for 
catalog '%s': %s" ],
+    "sqlState" : "42000"
+  },
+  "CANNOT_MUTATE_READ_ONLY_SQL_CONF" : {
+    "message" : [ "Cannot mutate ReadOnlySQLConf." ],
+    "sqlState" : "42000"
+  },
+  "CANNOT_SET_TIMEOUT_TIMESTAMP" : {
+    "message" : [ "Cannot set timeout timestamp without enabling event time 
timeout in [map|flatMapGroupsWithState" ],
+    "sqlState" : "42000"
+  },
+  "CATALOG_PLUGIN_CLASS_NOT_FOUND" : {
+    "message" : [ "Catalog '%s' plugin class not found: spark.sql.catalog.%s 
is not defined" ],
+    "sqlState" : "42000"

Review comment:
       42000 doesn't seem like the right SQLSTATE here. Maybe `3D000`?

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -1,8 +1,54 @@
 {
+  "ADD_FILES_WITH_ABSOLUTE_PATH_UNSUPPORTED" : {
+    "message" : [ "%s does not support adding files with an absolute path" ],
+    "sqlState" : "0A000"
+  },
   "AMBIGUOUS_FIELD_NAME" : {
     "message" : [ "Field name %s is ambiguous and has %s matching fields in 
the struct." ],
     "sqlState" : "42000"
   },
+  "BATCH_METADATA_FILE_NOT_FOUND" : {
+    "message" : [ "Unable to find batch %s" ]
+  },
+  "CANNOT_CLONE_OR_COPY_READ_ONLY_SQL_CONF" : {
+    "message" : [ "Cannot clone/copy ReadOnlySQLConf." ],
+    "sqlState" : "42000"
+  },
+  "CANNOT_EXECUTE_STREAMING_RELATION_EXEC" : {
+    "message" : [ "StreamingRelationExec cannot be executed" ],
+    "sqlState" : "42000"

Review comment:
       This is an internal error; we should remove the SQLSTATE.




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