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



##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -63,5 +63,67 @@
   "WRITING_JOB_ABORTED" : {
     "message" : [ "Writing job aborted" ],
     "sqlState" : "40000"
+  },
+  "UNSUPPORTED_CHANGE_COLUMN" : {
+    "message" : [ "Please add an implementation for a column change here" ],
+    "sqlState" : "46110"

Review comment:
       46110 is not in the SQLSTATE standard; I believe that `0A000` is the 
standard SQLSTATE for unsupported operations.

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -63,5 +63,67 @@
   "WRITING_JOB_ABORTED" : {
     "message" : [ "Writing job aborted" ],
     "sqlState" : "40000"
+  },
+  "UNSUPPORTED_CHANGE_COLUMN" : {
+    "message" : [ "Please add an implementation for a column change here" ],
+    "sqlState" : "46110"
+  },
+  "LOGICAL_HINT_OPERATOR_NOT_REMOVE_DURING_ANALYSIS" : {
+    "message" : [ "Internal error: logical hint operator should have been 
removed during analysis" ],
+    "sqlState" : "42000"
+  },
+  "CAN_NOT_EVALUATE_EXPRESSION" : {

Review comment:
       Nit: I think `cannot` is more common than `can not`.

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -63,5 +63,67 @@
   "WRITING_JOB_ABORTED" : {
     "message" : [ "Writing job aborted" ],
     "sqlState" : "40000"
+  },
+  "UNSUPPORTED_CHANGE_COLUMN" : {
+    "message" : [ "Please add an implementation for a column change here" ],
+    "sqlState" : "46110"
+  },
+  "LOGICAL_HINT_OPERATOR_NOT_REMOVE_DURING_ANALYSIS" : {
+    "message" : [ "Internal error: logical hint operator should have been 
removed during analysis" ],
+    "sqlState" : "42000"

Review comment:
       I don't think that internal errors count as syntax or semantic errors 
(42000); it may be simpler to remove the SQLSTATE entirely.

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -63,5 +63,67 @@
   "WRITING_JOB_ABORTED" : {
     "message" : [ "Writing job aborted" ],
     "sqlState" : "40000"
+  },
+  "UNSUPPORTED_CHANGE_COLUMN" : {
+    "message" : [ "Please add an implementation for a column change here" ],
+    "sqlState" : "46110"
+  },
+  "LOGICAL_HINT_OPERATOR_NOT_REMOVE_DURING_ANALYSIS" : {
+    "message" : [ "Internal error: logical hint operator should have been 
removed during analysis" ],
+    "sqlState" : "42000"
+  },
+  "CAN_NOT_EVALUATE_EXPRESSION" : {
+    "message" : [ "Cannot evaluate expression: %s: %s" ],
+    "sqlState" : "42000"
+  },
+  "CAN_NOT_GENERATE_CODE_FOR_EXPRESSION" : {
+    "message" : [ "Cannot generate code for expression: %s" ],
+    "sqlState" : "42000"
+  },
+  "CAN_NOT_TERMINATE_GENERATOR" : {
+    "message" : [ "Cannot terminate expression: %s" ],
+    "sqlState" : "42000"
+  },
+  "CAST_CAUSE_OVERFLOW" : {
+    "message" : [ "Casting %s to %s causes overflow" ],
+    "sqlState" : "22018"
+  },
+  "CAN_NOT_CHANGE_DECIMAL_PRECISION" : {
+    "message" : [ "%s cannot be represented as Decimal(%s, %s)." ],
+    "sqlState" : "HY104"
+  },
+  "INVALID_INPUT_SYNTAX_FOR_NUMERIC" : {
+    "message" : [ "invalid input syntax for type numeric: %s" ],
+    "sqlState" : "42000"
+  },
+  "CAN_NOT_CAST_DATATYPE" : {
+    "message" : [ "Cannot cast %s to %s." ],
+    "sqlState" : "22018"
+  },
+  "CAN_NOT_PARSE_DECIMAL" : {
+    "message" : [ "Cannot parse any decimal" ],
+    "sqlState" : "42000"
+  },
+  "UNSUPPORTED_SIMPLESTRING_WITH_NODEID" : {

Review comment:
       Nit: `SIMPLESTRING` -> `SIMPLE_STRING`

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -63,5 +63,67 @@
   "WRITING_JOB_ABORTED" : {
     "message" : [ "Writing job aborted" ],
     "sqlState" : "40000"
+  },
+  "UNSUPPORTED_CHANGE_COLUMN" : {
+    "message" : [ "Please add an implementation for a column change here" ],
+    "sqlState" : "46110"
+  },
+  "LOGICAL_HINT_OPERATOR_NOT_REMOVE_DURING_ANALYSIS" : {
+    "message" : [ "Internal error: logical hint operator should have been 
removed during analysis" ],
+    "sqlState" : "42000"
+  },
+  "CAN_NOT_EVALUATE_EXPRESSION" : {
+    "message" : [ "Cannot evaluate expression: %s: %s" ],
+    "sqlState" : "42000"
+  },
+  "CAN_NOT_GENERATE_CODE_FOR_EXPRESSION" : {
+    "message" : [ "Cannot generate code for expression: %s" ],
+    "sqlState" : "42000"
+  },
+  "CAN_NOT_TERMINATE_GENERATOR" : {
+    "message" : [ "Cannot terminate expression: %s" ],
+    "sqlState" : "42000"
+  },
+  "CAST_CAUSE_OVERFLOW" : {
+    "message" : [ "Casting %s to %s causes overflow" ],
+    "sqlState" : "22018"
+  },
+  "CAN_NOT_CHANGE_DECIMAL_PRECISION" : {
+    "message" : [ "%s cannot be represented as Decimal(%s, %s)." ],
+    "sqlState" : "HY104"
+  },
+  "INVALID_INPUT_SYNTAX_FOR_NUMERIC" : {
+    "message" : [ "invalid input syntax for type numeric: %s" ],
+    "sqlState" : "42000"
+  },
+  "CAN_NOT_CAST_DATATYPE" : {
+    "message" : [ "Cannot cast %s to %s." ],
+    "sqlState" : "22018"
+  },
+  "CAN_NOT_PARSE_DECIMAL" : {
+    "message" : [ "Cannot parse any decimal" ],
+    "sqlState" : "42000"
+  },
+  "UNSUPPORTED_SIMPLESTRING_WITH_NODEID" : {
+    "message" : [ "%s does not implement simpleStringWithNodeId" ],
+    "sqlState" : "46110"
+  },
+  "UNSUPPORTED_DATATYPE" : {
+    "message" : [ "Unsupported data type %s %s" ],
+    "sqlState" : "46110"
+  },
+  "FAILED_EXECUTE_UDF" : {
+    "message" : [ "Failed to execute user defined function (%s: (%s) => %s)" ],
+    "sqlState" : "42000"

Review comment:
       I'm not sure if 42000 is the right SQLSTATE here; maybe 45000 is a 
better fit.

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala
##########
@@ -67,89 +68,116 @@ import org.apache.spark.util.CircularBuffer
 object QueryExecutionErrors {
 
   def columnChangeUnsupportedError(): Throwable = {
-    new UnsupportedOperationException("Please add an implementation for a 
column change here")
+    new UnsupportedOperationException(

Review comment:
       Can you add a new exception type that mixes 
`UnsupportedOperationException` with `SparkThrowable`? It'd look like 
[`SparkArithmeticException`](https://github.com/apache/spark/blob/f90eb6a5db0778fd18b0b544f93eac3103bbf03b/core/src/main/scala/org/apache/spark/SparkException.scala#L75).
 Then we can catch these exceptions and use their error classes/SQLSTATEs.

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala
##########
@@ -67,89 +68,116 @@ import org.apache.spark.util.CircularBuffer
 object QueryExecutionErrors {
 
   def columnChangeUnsupportedError(): Throwable = {
-    new UnsupportedOperationException("Please add an implementation for a 
column change here")
+    new UnsupportedOperationException(
+      SparkThrowableHelper.getMessage("UNSUPPORTED_CHANGE_COLUMN",
+        Array.empty))
   }
 
   def logicalHintOperatorNotRemovedDuringAnalysisError(): Throwable = {
     new IllegalStateException(
-      "Internal error: logical hint operator should have been removed during 
analysis")
+      
SparkThrowableHelper.getMessage("LOGICAL_HINT_OPERATOR_NOT_REMOVE_DURING_ANALYSIS",
+        Array.empty))
   }
 
   def cannotEvaluateExpressionError(expression: Expression): Throwable = {
-    new UnsupportedOperationException(s"Cannot evaluate expression: 
$expression")
+    new UnsupportedOperationException(
+      SparkThrowableHelper.getMessage("CAN_NOT_EVALUATE_EXPRESSION",
+        Array("", expression.toString)))
   }
 
   def cannotGenerateCodeForExpressionError(expression: Expression): Throwable 
= {
-    new UnsupportedOperationException(s"Cannot generate code for expression: 
$expression")
+    new UnsupportedOperationException(
+      SparkThrowableHelper.getMessage("CAN_NOT_GENERATE_CODE_FOR_EXPRESSION",
+        Array(expression.toString)))
   }
 
   def cannotTerminateGeneratorError(generator: UnresolvedGenerator): Throwable 
= {
-    new UnsupportedOperationException(s"Cannot terminate expression: 
$generator")
+    new UnsupportedOperationException(
+      SparkThrowableHelper.getMessage("CAN_NOT_TERMINATE_GENERATOR",
+        Array(generator.toString)))
   }
 
   def castingCauseOverflowError(t: Any, targetType: String): 
ArithmeticException = {
-    new ArithmeticException(s"Casting $t to $targetType causes overflow")
+    new ArithmeticException(

Review comment:
       You can use `SparkArithmeticException` here instead.

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala
##########
@@ -67,89 +68,116 @@ import org.apache.spark.util.CircularBuffer
 object QueryExecutionErrors {
 
   def columnChangeUnsupportedError(): Throwable = {
-    new UnsupportedOperationException("Please add an implementation for a 
column change here")
+    new UnsupportedOperationException(
+      SparkThrowableHelper.getMessage("UNSUPPORTED_CHANGE_COLUMN",
+        Array.empty))
   }
 
   def logicalHintOperatorNotRemovedDuringAnalysisError(): Throwable = {
     new IllegalStateException(

Review comment:
       Same thing here - we'll need to create a couple new exception classes.




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