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/08/25 14:25:26 UTC

[GitHub] [spark] dgd-contributor opened a new pull request #33836: [WIP][SPARK-36293][SQL] Refactor fourth set of 20 query execution errors to use error classes

dgd-contributor opened a new pull request #33836:
URL: https://github.com/apache/spark/pull/33836


   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'core/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   Refactor some exceptions in QueryExecutionErrors to use error classes.
   There are currently ~350 exceptions in this file; so this PR only focuses on the fourth set of 20.
   
   > unableToCreateDatabaseAsFailedToCreateDirectoryError
   > unableToDropDatabaseAsFailedToDeleteDirectoryError
   > unableToCreateTableAsFailedToCreateDirectoryError
   > unableToDeletePartitionPathError
   > unableToDropTableAsFailedToDeleteDirectoryError
   > unableToRenameTableAsFailedToRenameDirectoryError
   > unableToCreatePartitionPathError
   > unableToRenamePartitionPathError
   > methodNotImplementedError
   > tableStatsNotSpecifiedError
   > unaryMinusCauseOverflowError
   > binaryArithmeticCauseOverflowError
   > failedSplitSubExpressionMsg
   > failedSplitSubExpressionError
   > failedToCompileMsg
   > internalCompilerError
   > compilerError
   > unsupportedTableChangeError
   > notADatasourceRDDPartitionError
   > dataPathNotSpecifiedError
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   https://issues.apache.org/jira/browse/SPARK-36094
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   No
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   -->
   Pass all current tests


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


[GitHub] [spark] dgd-contributor commented on a change in pull request #33836: [SPARK-36293][SQL] Refactor fourth set of 20 query execution errors to use error classes

Posted by GitBox <gi...@apache.org>.
dgd-contributor commented on a change in pull request #33836:
URL: https://github.com/apache/spark/pull/33836#discussion_r714860025



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala
##########
@@ -341,94 +342,94 @@ object QueryExecutionErrors {
 
   def unableToCreateDatabaseAsFailedToCreateDirectoryError(
       dbDefinition: CatalogDatabase, e: IOException): Throwable = {
-    new SparkException(s"Unable to create database ${dbDefinition.name} as failed " +
-      s"to create its directory ${dbDefinition.locationUri}", e)
+    new SparkException("CANNOT_CREATE_OBJECT_DUE_TO_FAILED_DIRECTORY_CREATION",
+      Array("DATABASE", dbDefinition.name, dbDefinition.locationUri.toString), e)
   }
 
   def unableToDropDatabaseAsFailedToDeleteDirectoryError(
       dbDefinition: CatalogDatabase, e: IOException): Throwable = {
-    new SparkException(s"Unable to drop database ${dbDefinition.name} as failed " +
-      s"to delete its directory ${dbDefinition.locationUri}", e)
+    new SparkException("CANNOT_DROP_OBJECT_DUE_TO_FAILED_DIRECTORY_DELETION",
+      Array("DATABASE", dbDefinition.name, dbDefinition.locationUri.toString), e)
   }
 
   def unableToCreateTableAsFailedToCreateDirectoryError(
       table: String, defaultTableLocation: Path, e: IOException): Throwable = {
-    new SparkException(s"Unable to create table $table as failed " +
-      s"to create its directory $defaultTableLocation", e)
+    new SparkException("CANNOT_CREATE_OBJECT_DUE_TO_FAILED_DIRECTORY_CREATION",
+      Array("TABLE", table, defaultTableLocation.toString), e)
   }
 
   def unableToDeletePartitionPathError(partitionPath: Path, e: IOException): Throwable = {
-    new SparkException(s"Unable to delete partition path $partitionPath", e)
+    new SparkException("UNABLE_DELETE_PARTITION", Array(partitionPath.toString), e)

Review comment:
       thank you! I checked and updated the mistake. Please take another look when you have time!




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


[GitHub] [spark] dgd-contributor commented on pull request #33836: [SPARK-36293][SQL] Refactor fourth set of 20 query execution errors to use error classes

Posted by GitBox <gi...@apache.org>.
dgd-contributor commented on pull request #33836:
URL: https://github.com/apache/spark/pull/33836#issuecomment-935280084


   @karenfeng thanks for your review! Could you please take a look at this PR https://github.com/apache/spark/pull/34190 when you have time? I will close this one. Sorry about the inconvenience!


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


[GitHub] [spark] dgd-contributor commented on a change in pull request #33836: [SPARK-36293][SQL] Refactor fourth set of 20 query execution errors to use error classes

Posted by GitBox <gi...@apache.org>.
dgd-contributor commented on a change in pull request #33836:
URL: https://github.com/apache/spark/pull/33836#discussion_r719882609



##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -11,6 +15,18 @@
     "message" : [ "%s cannot be represented as Decimal(%s, %s)." ],
     "sqlState" : "22005"
   },
+  "CANNOT_CREATE_OBJECT_DUE_TO_FAILED_DIRECTORY_CREATION" : {
+    "message" : [ "Unable to CREATE %s %s as failed to create its directory %s." ]
+  },
+  "CANNOT_CREATE_PARTITION" : {

Review comment:
       cc @karenfeng , Could you please help me review it again? Thank you!




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


[GitHub] [spark] dgd-contributor closed pull request #33836: [SPARK-36293][SQL] Refactor fourth set of 20 query execution errors to use error classes

Posted by GitBox <gi...@apache.org>.
dgd-contributor closed pull request #33836:
URL: https://github.com/apache/spark/pull/33836


   


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


[GitHub] [spark] karenfeng commented on a change in pull request #33836: [SPARK-36293][SQL] Refactor fourth set of 20 query execution errors to use error classes

Posted by GitBox <gi...@apache.org>.
karenfeng commented on a change in pull request #33836:
URL: https://github.com/apache/spark/pull/33836#discussion_r717202777



##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -11,6 +15,18 @@
     "message" : [ "%s cannot be represented as Decimal(%s, %s)." ],
     "sqlState" : "22005"
   },
+  "CANNOT_CREATE_OBJECT_DUE_TO_FAILED_DIRECTORY_CREATION" : {
+    "message" : [ "Unable to CREATE %s %s as failed to create its directory %s." ]
+  },
+  "CANNOT_CREATE_PARTITION" : {

Review comment:
       "partition" is pretty overloaded in Spark, maybe we should make this `CANNOT_CREATE_PARTITION_PATH`. Then we should replace it for `CANNOT_DELETE PARTITION` and so on too.




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


[GitHub] [spark] karenfeng commented on a change in pull request #33836: [SPARK-36293][SQL] Refactor fourth set of 20 query execution errors to use error classes

Posted by GitBox <gi...@apache.org>.
karenfeng commented on a change in pull request #33836:
URL: https://github.com/apache/spark/pull/33836#discussion_r714209644



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala
##########
@@ -341,94 +342,94 @@ object QueryExecutionErrors {
 
   def unableToCreateDatabaseAsFailedToCreateDirectoryError(
       dbDefinition: CatalogDatabase, e: IOException): Throwable = {
-    new SparkException(s"Unable to create database ${dbDefinition.name} as failed " +
-      s"to create its directory ${dbDefinition.locationUri}", e)
+    new SparkException("CANNOT_CREATE_OBJECT_DUE_TO_FAILED_DIRECTORY_CREATION",
+      Array("DATABASE", dbDefinition.name, dbDefinition.locationUri.toString), e)
   }
 
   def unableToDropDatabaseAsFailedToDeleteDirectoryError(
       dbDefinition: CatalogDatabase, e: IOException): Throwable = {
-    new SparkException(s"Unable to drop database ${dbDefinition.name} as failed " +
-      s"to delete its directory ${dbDefinition.locationUri}", e)
+    new SparkException("CANNOT_DROP_OBJECT_DUE_TO_FAILED_DIRECTORY_DELETION",
+      Array("DATABASE", dbDefinition.name, dbDefinition.locationUri.toString), e)
   }
 
   def unableToCreateTableAsFailedToCreateDirectoryError(
       table: String, defaultTableLocation: Path, e: IOException): Throwable = {
-    new SparkException(s"Unable to create table $table as failed " +
-      s"to create its directory $defaultTableLocation", e)
+    new SparkException("CANNOT_CREATE_OBJECT_DUE_TO_FAILED_DIRECTORY_CREATION",
+      Array("TABLE", table, defaultTableLocation.toString), e)
   }
 
   def unableToDeletePartitionPathError(partitionPath: Path, e: IOException): Throwable = {
-    new SparkException(s"Unable to delete partition path $partitionPath", e)
+    new SparkException("UNABLE_DELETE_PARTITION", Array(partitionPath.toString), e)

Review comment:
       These error class names should be updated to match those in the JSON.

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -134,9 +155,35 @@
     "message" : [ "The second argument of '%s' function needs to be an integer." ],
     "sqlState" : "22023"
   },
+  "TABLE_STATS_NOT_SPECIFIED" : {

Review comment:
       Nit: `STATS` -> `STATISTICS`




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


[GitHub] [spark] dgd-contributor commented on pull request #33836: [SPARK-36293][SQL] Refactor fourth set of 20 query execution errors to use error classes

Posted by GitBox <gi...@apache.org>.
dgd-contributor commented on pull request #33836:
URL: https://github.com/apache/spark/pull/33836#issuecomment-923598460


   @karenfeng Please take a look when you have time. Thank you so much!


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


[GitHub] [spark] dgd-contributor commented on a change in pull request #33836: [SPARK-36293][SQL] Refactor fourth set of 20 query execution errors to use error classes

Posted by GitBox <gi...@apache.org>.
dgd-contributor commented on a change in pull request #33836:
URL: https://github.com/apache/spark/pull/33836#discussion_r714860025



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala
##########
@@ -341,94 +342,94 @@ object QueryExecutionErrors {
 
   def unableToCreateDatabaseAsFailedToCreateDirectoryError(
       dbDefinition: CatalogDatabase, e: IOException): Throwable = {
-    new SparkException(s"Unable to create database ${dbDefinition.name} as failed " +
-      s"to create its directory ${dbDefinition.locationUri}", e)
+    new SparkException("CANNOT_CREATE_OBJECT_DUE_TO_FAILED_DIRECTORY_CREATION",
+      Array("DATABASE", dbDefinition.name, dbDefinition.locationUri.toString), e)
   }
 
   def unableToDropDatabaseAsFailedToDeleteDirectoryError(
       dbDefinition: CatalogDatabase, e: IOException): Throwable = {
-    new SparkException(s"Unable to drop database ${dbDefinition.name} as failed " +
-      s"to delete its directory ${dbDefinition.locationUri}", e)
+    new SparkException("CANNOT_DROP_OBJECT_DUE_TO_FAILED_DIRECTORY_DELETION",
+      Array("DATABASE", dbDefinition.name, dbDefinition.locationUri.toString), e)
   }
 
   def unableToCreateTableAsFailedToCreateDirectoryError(
       table: String, defaultTableLocation: Path, e: IOException): Throwable = {
-    new SparkException(s"Unable to create table $table as failed " +
-      s"to create its directory $defaultTableLocation", e)
+    new SparkException("CANNOT_CREATE_OBJECT_DUE_TO_FAILED_DIRECTORY_CREATION",
+      Array("TABLE", table, defaultTableLocation.toString), e)
   }
 
   def unableToDeletePartitionPathError(partitionPath: Path, e: IOException): Throwable = {
-    new SparkException(s"Unable to delete partition path $partitionPath", e)
+    new SparkException("UNABLE_DELETE_PARTITION", Array(partitionPath.toString), e)

Review comment:
       thank you! I checked and updated the mistake. Please take another when you have time!




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


[GitHub] [spark] dgd-contributor commented on a change in pull request #33836: [SPARK-36293][SQL] Refactor fourth set of 20 query execution errors to use error classes

Posted by GitBox <gi...@apache.org>.
dgd-contributor commented on a change in pull request #33836:
URL: https://github.com/apache/spark/pull/33836#discussion_r714068723



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/AnalysisException.scala
##########
@@ -94,3 +97,21 @@ class AnalysisException protected[sql] (
   override def getErrorClass: String = errorClass.orNull
   override def getSqlState: String = SparkThrowableHelper.getSqlState(errorClass.orNull)
 }
+
+class SparkInternalCompilerException(errorClass: String, messageParameters: Array[String])

Review comment:
       Thanks @karenfeng , I think SQL Catalyst is the good place to put those new exceptions. And if we put them to ```core/.../SparkException.scala``` we will need add ```org.codehaus.janino``` dependency in core's ```pom.xml```




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


[GitHub] [spark] AmplabJenkins commented on pull request #33836: [WIP][SPARK-36293][SQL] Refactor fourth set of 20 query execution errors to use error classes

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33836:
URL: https://github.com/apache/spark/pull/33836#issuecomment-905570631


   Can one of the admins verify this patch?


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


[GitHub] [spark] karenfeng commented on a change in pull request #33836: [SPARK-36293][SQL] Refactor fourth set of 20 query execution errors to use error classes

Posted by GitBox <gi...@apache.org>.
karenfeng commented on a change in pull request #33836:
URL: https://github.com/apache/spark/pull/33836#discussion_r714207534



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/AnalysisException.scala
##########
@@ -94,3 +97,21 @@ class AnalysisException protected[sql] (
   override def getErrorClass: String = errorClass.orNull
   override def getSqlState: String = SparkThrowableHelper.getSqlState(errorClass.orNull)
 }
+
+class SparkInternalCompilerException(errorClass: String, messageParameters: Array[String])

Review comment:
       That makes sense. Thanks!




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


[GitHub] [spark] karenfeng commented on a change in pull request #33836: [SPARK-36293][SQL] Refactor fourth set of 20 query execution errors to use error classes

Posted by GitBox <gi...@apache.org>.
karenfeng commented on a change in pull request #33836:
URL: https://github.com/apache/spark/pull/33836#discussion_r717202777



##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -11,6 +15,18 @@
     "message" : [ "%s cannot be represented as Decimal(%s, %s)." ],
     "sqlState" : "22005"
   },
+  "CANNOT_CREATE_OBJECT_DUE_TO_FAILED_DIRECTORY_CREATION" : {
+    "message" : [ "Unable to CREATE %s %s as failed to create its directory %s." ]
+  },
+  "CANNOT_CREATE_PARTITION" : {

Review comment:
       "partition" is pretty overloaded in Spark, maybe we should make this `CANNOT_CREATE_PARTITION_PATH`. Then we should replace it for `CANNOT_DELETE PARTITION` and so on too.




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


[GitHub] [spark] karenfeng commented on a change in pull request #33836: [SPARK-36293][SQL] Refactor fourth set of 20 query execution errors to use error classes

Posted by GitBox <gi...@apache.org>.
karenfeng commented on a change in pull request #33836:
URL: https://github.com/apache/spark/pull/33836#discussion_r713447468



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/AnalysisException.scala
##########
@@ -94,3 +97,21 @@ class AnalysisException protected[sql] (
   override def getErrorClass: String = errorClass.orNull
   override def getSqlState: String = SparkThrowableHelper.getSqlState(errorClass.orNull)
 }
+
+class SparkInternalCompilerException(errorClass: String, messageParameters: Array[String])

Review comment:
       These should be package-private; see the classes in `SparkException.scala` for more detail.

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -3,6 +3,10 @@
     "message" : [ "Field name %s is ambiguous and has %s matching fields in the struct." ],
     "sqlState" : "42000"
   },
+  "BINARY_ARITHMETIC_CAUSE_OVERFLOW" : {

Review comment:
       We can simplify this; `BINARY_ARITHMETIC_CAUSE_OVERFLOW` -> `BINARY_ARITHMETIC_OVERFLOW`

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -39,6 +46,10 @@
     "message" : [ "Found duplicate keys '%s'" ],
     "sqlState" : "23000"
   },
+  "FAILED_COMPILE_MSG" : {

Review comment:
       We can also simplify this: `FAILED_COMPILE_MSG` -> `COMPILATION_FAILED`

##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/AnalysisException.scala
##########
@@ -94,3 +97,21 @@ class AnalysisException protected[sql] (
   override def getErrorClass: String = errorClass.orNull
   override def getSqlState: String = SparkThrowableHelper.getSqlState(errorClass.orNull)
 }
+
+class SparkInternalCompilerException(errorClass: String, messageParameters: Array[String])
+  extends InternalCompilerException(SparkThrowableHelper.getMessage(errorClass, messageParameters))
+    with SparkThrowable {
+  override def getErrorClass: String = errorClass
+  override def getSqlState: String = SparkThrowableHelper.getSqlState(errorClass)
+}
+
+class SparkCompileException(
+    errorClass: String,
+    messageParameters: Array[String],
+    e: CompileException)

Review comment:
       Do we need `e`? Can we just pass the location?

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

Review comment:
       `FAILED_SPLIT_SUB_EXPRESSION_MSG` -> `FAILED_SPLIT_SUBEXPRESSION`

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -98,6 +112,9 @@
   "MAP_KEY_DOES_NOT_EXIST" : {
     "message" : [ "Key %s does not exist." ]
   },
+  "METHOD_NOT_IMPLEMENTED" : {
+    "message" : [ "%s is not implemented" ]

Review comment:
       We can add the SQLSTATE `0A000` here.

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -39,6 +46,10 @@
     "message" : [ "Found duplicate keys '%s'" ],
     "sqlState" : "23000"
   },
+  "FAILED_COMPILE_MSG" : {
+    "message" : [ "failed to compile: %s" ],
+    "sqlState" : "42000"

Review comment:
       I'm not sure if this is a syntax error, but I also can't find a relevant SQLSTATE. Maybe we can leave the SQLSTATE empty for now?

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -134,9 +154,41 @@
     "message" : [ "The second argument of '%s' function needs to be an integer." ],
     "sqlState" : "22023"
   },
+  "TABLE_STATS_MUST_SPECIFIED" : {
+    "message" : [ "table stats must be specified." ],
+    "sqlState" : "42000"
+  },
+  "UNABLE_CREATE_DATABASE_AS_FAILED_CREATE_DIRECTORY" : {
+    "message" : [ "Unable to create database %s as failed to create its directory %s" ]
+  },
+  "UNABLE_CREATE_PARTITION" : {
+    "message" : [ "Unable to create partition path %s" ]
+  },
+  "UNABLE_CREATE_TABLE_AS_FAILED_CREATE_DIRECTORY" : {
+    "message" : [ "Unable to create table %s as failed to create its directory %s" ]
+  },
+  "UNABLE_DELETE_PARTITION" : {
+    "message" : [ "Unable to delete partition path %s" ]
+  },
+  "UNABLE_DROP_DATABASE_AS_FAILED_DELETE_DIRECTORY" : {
+    "message" : [ "Unable to drop database %s as failed to delete its directory %s" ]
+  },
+  "UNABLE_DROP_TABLE_AS_FAILED_DELETE_DIRECTORY" : {
+    "message" : [ "Unable to drop table %s as failed to delete its directory %s" ]
+  },
+  "UNABLE_RENAME_PARTITION" : {
+    "message" : [ "Unable to rename partition path %s" ]
+  },
+  "UNABLE_RENAME_TABLE_AS_FAILED_RENAME_DIRECTORY" : {
+    "message" : [ "Unable to rename table %s to %s as failed to rename its directory %s" ]
+  },
   "UNABLE_TO_ACQUIRE_MEMORY" : {
     "message" : [ "Unable to acquire %s bytes of memory, got %s" ]
   },
+  "UNARY_MINUS_CAUSE_OVERFLOW" : {
+    "message" : [ "- %s caused overflow." ],
+    "sqlState" : "22015"

Review comment:
       `22003` is probably a better fit for the SQLSTATE.

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -3,6 +3,10 @@
     "message" : [ "Field name %s is ambiguous and has %s matching fields in the struct." ],
     "sqlState" : "42000"
   },
+  "BINARY_ARITHMETIC_CAUSE_OVERFLOW" : {
+    "message" : [ "%s %s %s caused overflow." ],
+    "sqlState" : "22015"

Review comment:
       22015 is specific to interval fields. 22003 may be a better fit here.

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -134,9 +154,41 @@
     "message" : [ "The second argument of '%s' function needs to be an integer." ],
     "sqlState" : "22023"
   },
+  "TABLE_STATS_MUST_SPECIFIED" : {

Review comment:
       `TABLE_STATS_MUST_SPECIFIED` -> `TABLE_STATS_NOT_SPECIFIED`

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -134,9 +154,41 @@
     "message" : [ "The second argument of '%s' function needs to be an integer." ],
     "sqlState" : "22023"
   },
+  "TABLE_STATS_MUST_SPECIFIED" : {
+    "message" : [ "table stats must be specified." ],
+    "sqlState" : "42000"
+  },
+  "UNABLE_CREATE_DATABASE_AS_FAILED_CREATE_DIRECTORY" : {
+    "message" : [ "Unable to create database %s as failed to create its directory %s" ]
+  },
+  "UNABLE_CREATE_PARTITION" : {
+    "message" : [ "Unable to create partition path %s" ]
+  },
+  "UNABLE_CREATE_TABLE_AS_FAILED_CREATE_DIRECTORY" : {
+    "message" : [ "Unable to create table %s as failed to create its directory %s" ]
+  },
+  "UNABLE_DELETE_PARTITION" : {

Review comment:
       `UNABLE` -> `CANNOT`

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -31,6 +35,9 @@
   "CONCURRENT_QUERY" : {
     "message" : [ "Another instance of this query was just started by a concurrent session." ]
   },
+  "DATA_PATH_NOT_SPECIFIED" : {
+    "message" : [ "'path' is not specified" ]

Review comment:
       There should be a SQLSTATE here. I think `42000` is probably the best fit?

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -134,9 +154,41 @@
     "message" : [ "The second argument of '%s' function needs to be an integer." ],
     "sqlState" : "22023"
   },
+  "TABLE_STATS_MUST_SPECIFIED" : {
+    "message" : [ "table stats must be specified." ],
+    "sqlState" : "42000"
+  },
+  "UNABLE_CREATE_DATABASE_AS_FAILED_CREATE_DIRECTORY" : {

Review comment:
       We can probably consolidate `UNABLE_CREATE_DATABASE_AS_FAILED_CREATE_DIRECTORY` and `UNABLE_CREATE_TABLE_AS_FAILED_CREATE_DIRECTORY`, i.e.:
   
   ```
   "CANNOT_CREATE_OBJECT_DUE_TO_FAILED_DIRECTORY_CREATION": {
     "message": [ "Unable to CREATE %s %s as failed to create its directory %s. " ]
   }
   ```
   
   Where this is called with:
   ```
   new SparkException("CANNOT_CREATE_OBJECT_DUE_TO_FAILED_DIRECTORY_CREATION",
         Array("DATABASE", dbDefinition.name, dbDefinition.locationUri.toString), e)
   ```

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -134,9 +154,41 @@
     "message" : [ "The second argument of '%s' function needs to be an integer." ],
     "sqlState" : "22023"
   },
+  "TABLE_STATS_MUST_SPECIFIED" : {
+    "message" : [ "table stats must be specified." ],
+    "sqlState" : "42000"
+  },
+  "UNABLE_CREATE_DATABASE_AS_FAILED_CREATE_DIRECTORY" : {
+    "message" : [ "Unable to create database %s as failed to create its directory %s" ]
+  },
+  "UNABLE_CREATE_PARTITION" : {

Review comment:
       `UNABLE` -> `CANNOT`

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -134,9 +154,41 @@
     "message" : [ "The second argument of '%s' function needs to be an integer." ],
     "sqlState" : "22023"
   },
+  "TABLE_STATS_MUST_SPECIFIED" : {
+    "message" : [ "table stats must be specified." ],
+    "sqlState" : "42000"
+  },
+  "UNABLE_CREATE_DATABASE_AS_FAILED_CREATE_DIRECTORY" : {
+    "message" : [ "Unable to create database %s as failed to create its directory %s" ]
+  },
+  "UNABLE_CREATE_PARTITION" : {
+    "message" : [ "Unable to create partition path %s" ]
+  },
+  "UNABLE_CREATE_TABLE_AS_FAILED_CREATE_DIRECTORY" : {
+    "message" : [ "Unable to create table %s as failed to create its directory %s" ]
+  },
+  "UNABLE_DELETE_PARTITION" : {
+    "message" : [ "Unable to delete partition path %s" ]
+  },
+  "UNABLE_DROP_DATABASE_AS_FAILED_DELETE_DIRECTORY" : {

Review comment:
       We can probably consolidate this error message and the one below; i.e.:
   
   ```
   "CANNOT_DROP_OBJECT_DUE_TO_FAILED_DIRECTORY_DELETION": {
     "message": [ "Unable to DROP %s %s as failed to delete its directory %s. " ]
   }
   ```
   
   Where this is called with:
   ```
   new SparkException("CANNOT_DROP_OBJECT_DUE_TO_FAILED_DIRECTORY_DELETION",
         Array("DATABASE", dbDefinition.name, dbDefinition.locationUri.toString), e)
   ```

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -134,9 +154,41 @@
     "message" : [ "The second argument of '%s' function needs to be an integer." ],
     "sqlState" : "22023"
   },
+  "TABLE_STATS_MUST_SPECIFIED" : {
+    "message" : [ "table stats must be specified." ],
+    "sqlState" : "42000"
+  },
+  "UNABLE_CREATE_DATABASE_AS_FAILED_CREATE_DIRECTORY" : {
+    "message" : [ "Unable to create database %s as failed to create its directory %s" ]
+  },
+  "UNABLE_CREATE_PARTITION" : {
+    "message" : [ "Unable to create partition path %s" ]
+  },
+  "UNABLE_CREATE_TABLE_AS_FAILED_CREATE_DIRECTORY" : {
+    "message" : [ "Unable to create table %s as failed to create its directory %s" ]
+  },
+  "UNABLE_DELETE_PARTITION" : {
+    "message" : [ "Unable to delete partition path %s" ]
+  },
+  "UNABLE_DROP_DATABASE_AS_FAILED_DELETE_DIRECTORY" : {
+    "message" : [ "Unable to drop database %s as failed to delete its directory %s" ]
+  },
+  "UNABLE_DROP_TABLE_AS_FAILED_DELETE_DIRECTORY" : {
+    "message" : [ "Unable to drop table %s as failed to delete its directory %s" ]
+  },
+  "UNABLE_RENAME_PARTITION" : {

Review comment:
       `UNABLE` -> `CANNOT`

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -134,9 +154,41 @@
     "message" : [ "The second argument of '%s' function needs to be an integer." ],
     "sqlState" : "22023"
   },
+  "TABLE_STATS_MUST_SPECIFIED" : {
+    "message" : [ "table stats must be specified." ],
+    "sqlState" : "42000"
+  },
+  "UNABLE_CREATE_DATABASE_AS_FAILED_CREATE_DIRECTORY" : {
+    "message" : [ "Unable to create database %s as failed to create its directory %s" ]
+  },
+  "UNABLE_CREATE_PARTITION" : {
+    "message" : [ "Unable to create partition path %s" ]
+  },
+  "UNABLE_CREATE_TABLE_AS_FAILED_CREATE_DIRECTORY" : {
+    "message" : [ "Unable to create table %s as failed to create its directory %s" ]
+  },
+  "UNABLE_DELETE_PARTITION" : {
+    "message" : [ "Unable to delete partition path %s" ]
+  },
+  "UNABLE_DROP_DATABASE_AS_FAILED_DELETE_DIRECTORY" : {
+    "message" : [ "Unable to drop database %s as failed to delete its directory %s" ]
+  },
+  "UNABLE_DROP_TABLE_AS_FAILED_DELETE_DIRECTORY" : {
+    "message" : [ "Unable to drop table %s as failed to delete its directory %s" ]
+  },
+  "UNABLE_RENAME_PARTITION" : {
+    "message" : [ "Unable to rename partition path %s" ]
+  },
+  "UNABLE_RENAME_TABLE_AS_FAILED_RENAME_DIRECTORY" : {

Review comment:
       `UNABLE_RENAME_TABLE_AS_FAILED_RENAME_DIRECTORY` -> `CANNOT_RENAME_TABLE_DUE_TO_FAILED_DIRECTORY_RENAMING`

##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/AnalysisException.scala
##########
@@ -94,3 +97,21 @@ class AnalysisException protected[sql] (
   override def getErrorClass: String = errorClass.orNull
   override def getSqlState: String = SparkThrowableHelper.getSqlState(errorClass.orNull)
 }
+
+class SparkInternalCompilerException(errorClass: String, messageParameters: Array[String])

Review comment:
       Also, is there a reason you chose to put this in SQL Catalyst instead of core with the other Spark exceptions?

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -134,9 +154,41 @@
     "message" : [ "The second argument of '%s' function needs to be an integer." ],
     "sqlState" : "22023"
   },
+  "TABLE_STATS_MUST_SPECIFIED" : {
+    "message" : [ "table stats must be specified." ],
+    "sqlState" : "42000"
+  },
+  "UNABLE_CREATE_DATABASE_AS_FAILED_CREATE_DIRECTORY" : {
+    "message" : [ "Unable to create database %s as failed to create its directory %s" ]
+  },
+  "UNABLE_CREATE_PARTITION" : {
+    "message" : [ "Unable to create partition path %s" ]
+  },
+  "UNABLE_CREATE_TABLE_AS_FAILED_CREATE_DIRECTORY" : {
+    "message" : [ "Unable to create table %s as failed to create its directory %s" ]
+  },
+  "UNABLE_DELETE_PARTITION" : {
+    "message" : [ "Unable to delete partition path %s" ]
+  },
+  "UNABLE_DROP_DATABASE_AS_FAILED_DELETE_DIRECTORY" : {
+    "message" : [ "Unable to drop database %s as failed to delete its directory %s" ]
+  },
+  "UNABLE_DROP_TABLE_AS_FAILED_DELETE_DIRECTORY" : {
+    "message" : [ "Unable to drop table %s as failed to delete its directory %s" ]
+  },
+  "UNABLE_RENAME_PARTITION" : {
+    "message" : [ "Unable to rename partition path %s" ]
+  },
+  "UNABLE_RENAME_TABLE_AS_FAILED_RENAME_DIRECTORY" : {
+    "message" : [ "Unable to rename table %s to %s as failed to rename its directory %s" ]
+  },
   "UNABLE_TO_ACQUIRE_MEMORY" : {
     "message" : [ "Unable to acquire %s bytes of memory, got %s" ]
   },
+  "UNARY_MINUS_CAUSE_OVERFLOW" : {

Review comment:
       `UNARY_MINUS_CAUSE_OVERFLOW` -> `UNARY_MINUS_OVERFLOW`




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


[GitHub] [spark] dgd-contributor commented on a change in pull request #33836: [SPARK-36293][SQL] Refactor fourth set of 20 query execution errors to use error classes

Posted by GitBox <gi...@apache.org>.
dgd-contributor commented on a change in pull request #33836:
URL: https://github.com/apache/spark/pull/33836#discussion_r714068723



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/AnalysisException.scala
##########
@@ -94,3 +97,21 @@ class AnalysisException protected[sql] (
   override def getErrorClass: String = errorClass.orNull
   override def getSqlState: String = SparkThrowableHelper.getSqlState(errorClass.orNull)
 }
+
+class SparkInternalCompilerException(errorClass: String, messageParameters: Array[String])

Review comment:
       Thanks @karenfeng , I think SQL Catalyst is the good place to put those new exception. And if we put them to ```core/.../SparkException.scala``` we will need add ```org.codehaus.janino``` dependency in core's ```pom.xml```




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