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 17:01:11 UTC

[GitHub] [spark] dgd-contributor opened a new pull request #33839: [SPARK-36291][SQL] refactor second set of 20 in QueryExecutionErrors to use error classes

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


   ### What changes were proposed in this pull request?
   
   Refactor some exceptions in QueryExecutionErrors to use error classes.
   
   ```
   inputTypeUnsupportedError
   invalidFractionOfSecondError
   overflowInSumOfDecimalError
   overflowInIntegralDivideError
   mapSizeExceedArraySizeWhenZipMapError
   copyNullFieldNotAllowedError
   literalTypeUnsupportedError
   noDefaultForDataTypeError
   doGenCodeOfAliasShouldNotBeCalledError
   orderedOperationUnsupportedByDataTypeError
   regexGroupIndexLessThanZeroError
   regexGroupIndexExceedGroupCountError
   invalidUrlError
   dataTypeOperationUnsupportedError
   mergeUnsupportedByWindowFunctionError
   dataTypeUnexpectedError
   typeUnsupportedError
   negativeValueUnexpectedError
   addNewFunctionMismatchedWithFunctionError
   cannotGenerateCodeForUncomparableTypeError
   ```
   ### Why are the changes needed?
   
   There are currently ~350 exceptions in this file; so this PR only focuses on the second set of 20.
   
   ### Does this PR introduce _any_ user-facing change?
   No
   ### How was this patch tested?
   Existed UT Testcase


-- 
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 #33839: [WIP][SPARK-36291][SQL] Refactor second set of 20 in QueryExecutionErrors to use error classes

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



##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -89,13 +122,31 @@
     "message" : [ "The second argument of '%s' function needs to be an integer." ],
     "sqlState" : "22023"
   },
+  "SHOULD_NOT_CALL_ALIAS_DO_GEN_CODE" : {
+    "message" : [ "Alias.doGenCode should not be called." ]
+  },
+  "SUM_OF_DECIMAL_OVERFLOW" : {
+    "message" : [ "Overflow in sum of decimals." ]
+  },
   "UNABLE_TO_ACQUIRE_MEMORY" : {
     "message" : [ "Unable to acquire %s bytes of memory, got %s" ]
   },
+  "UNEXPECTED_DATATYPE" : {

Review comment:
       can we merge them like
   ```
   "UNEXPECTED" : {
       "message" : [ "Unexpected %s" ],
       "sqlState" : "22000"
   ```
   




-- 
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 #33839: [WIP][SPARK-36291][SQL] Refactor second set of 20 in QueryExecutionErrors to use error classes

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


   > There is no suitable SQLSTATE for all error class added newly ?
   
   No I haven't working on adding sqlstate, I will add them shortly


-- 
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 #33839: [WIP][SPARK-36291][SQL] Refactor second set of 20 in QueryExecutionErrors to use error classes

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



##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -32,6 +46,14 @@
   "GROUPING_SIZE_LIMIT_EXCEEDED" : {
     "message" : [ "Grouping sets size cannot be greater than %s" ]
   },
+  "GROUP_INDEX_EXCEED_GROUP_COUNT" : {
+    "message" : [ "Regex group count is %s, but the specified group index is %s" ],
+    "sqlState" : "42000"
+  },
+  "GROUP_INDEX_LESS_THAN_ZERO" : {
+    "message" : [ "The specified group index cannot be less than zero" ],
+    "sqlState" : "07009"

Review comment:
       I think 42000 is a better fit here as well.

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

Review comment:
       This doesn't make much sense grammatically. How about `ADD_NEW_FUNCTION_NAME_MISMATCHED`?

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -89,17 +131,40 @@
     "message" : [ "The second argument of '%s' function needs to be an integer." ],
     "sqlState" : "22023"
   },
+  "SHOULD_NOT_CALL_ALIAS_DO_GEN_CODE" : {
+    "message" : [ "Alias.doGenCode should not be called." ]
+  },
+  "SUM_OF_DECIMAL_OVERFLOW" : {
+    "message" : [ "Overflow in sum of decimals." ],
+    "sqlState" : "22003"
+  },
   "UNABLE_TO_ACQUIRE_MEMORY" : {
     "message" : [ "Unable to acquire %s bytes of memory, got %s" ]
   },
+  "UNEXPECTED_TYPE" : {
+    "message" : [ "Unexpected type %s" ],
+    "sqlState" : "42000"
+  },
   "UNRECOGNIZED_SQL_TYPE" : {
     "message" : [ "Unrecognized SQL type %s" ],
     "sqlState" : "42000"
   },
+  "UNSUPPORTED_DATATYPE" : {
+    "message" : [ "dataType" ],
+    "sqlState" : "0A000"
+  },
+  "UNSUPPORTED_INPUT_TYPE" : {
+    "message" : [ "Unsupported input type %s" ],
+    "sqlState" : "0A000"
+  },
   "UNSUPPORTED_LITERAL_TYPE" : {
     "message" : [ "Unsupported literal type %s %s" ],
     "sqlState" : "0A000"
   },
+  "UNSUPPORTED_ORDERED_OPERATIONS" : {

Review comment:
       This should be more specific, like `ORDERED_OPERATIONS_UNSUPPORTED_BY_DATA_TYPE`

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -46,6 +68,10 @@
     "message" : [ "Index %s must be between 0 and the length of the ArrayData." ],
     "sqlState" : "22023"
   },
+  "INTEGRAL_DIVIDE_OVERFLOW" : {
+    "message" : [ "Overflow in integral divide." ],
+    "sqlState" : "22015"

Review comment:
       I think `22003` is a better fit here.

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -14,13 +21,20 @@
     "message" : [ "Found duplicate keys '%s'" ],
     "sqlState" : "23000"
   },
+  "EXCEED_ARRAY_SIZE_WHEN_ZIP_MAP" : {

Review comment:
       This doesn't make much sense grammatically. How about `ZIPPED_MAPS_EXCEED_SIZE_LIMIT`?

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -77,6 +111,14 @@
     "message" : [ "PARTITION clause cannot contain a non-partition column name: %s" ],
     "sqlState" : "42000"
   },
+  "NOT_MATCH_FUNCTION_NAME" : {
+    "message" : [ "%s is not matched at addNewFunction" ],
+    "sqlState" : "42000"

Review comment:
       This is an internal error, let's remove the SQLSTATE.

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -14,13 +21,20 @@
     "message" : [ "Found duplicate keys '%s'" ],
     "sqlState" : "23000"
   },
+  "EXCEED_ARRAY_SIZE_WHEN_ZIP_MAP" : {
+    "message" : [ "Unsuccessful try to zip maps with %s unique keys due to exceeding the array size limit %s." ]
+  },
   "FAILED_RENAME_PATH" : {
     "message" : [ "Failed to rename %s to %s as destination already exists" ],
     "sqlState" : "22023"
   },
   "FAILED_SET_ORIGINAL_PERMISSION_BACK" : {
     "message" : [ "Failed to set original permission %s back to the created path: %s. Exception: %s" ]
   },
+  "FOUND_NEGATIVE_VALUES" : {

Review comment:
       I think `UNEXPECTED_NEGATIVE_VALUES` is a better descriptor.

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -89,17 +131,40 @@
     "message" : [ "The second argument of '%s' function needs to be an integer." ],
     "sqlState" : "22023"
   },
+  "SHOULD_NOT_CALL_ALIAS_DO_GEN_CODE" : {
+    "message" : [ "Alias.doGenCode should not be called." ]
+  },
+  "SUM_OF_DECIMAL_OVERFLOW" : {
+    "message" : [ "Overflow in sum of decimals." ],
+    "sqlState" : "22003"
+  },
   "UNABLE_TO_ACQUIRE_MEMORY" : {
     "message" : [ "Unable to acquire %s bytes of memory, got %s" ]
   },
+  "UNEXPECTED_TYPE" : {
+    "message" : [ "Unexpected type %s" ],
+    "sqlState" : "42000"
+  },
   "UNRECOGNIZED_SQL_TYPE" : {
     "message" : [ "Unrecognized SQL type %s" ],
     "sqlState" : "42000"
   },
+  "UNSUPPORTED_DATATYPE" : {

Review comment:
       Nit: `DATATYPE` -> `DATA_TYPE`.

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -3,9 +3,16 @@
     "message" : [ "Field name %s is ambiguous and has %s matching fields in the struct." ],
     "sqlState" : "42000"
   },
+  "CANNOT_GENERATE_CODE_FOR_UNCOMPARABLE_TYPE" : {
+    "message" : [ "cannot generate %s code for un-comparable type: %s" ],
+    "sqlState" : "0A000"
+  },
   "CONCURRENT_QUERY" : {
     "message" : [ "Another instance of this query was just started by a concurrent session." ]
   },
+  "COPY_NULL_FIELD" : {

Review comment:
       I think `COPY_NULL_FIELD_NOT_ALLOWED` is a better descriptor.




-- 
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] HyukjinKwon commented on pull request #33839: [SPARK-36291][SQL] Refactor second set of 20 in QueryExecutionErrors to use error classes

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


   cc @karenfeng FYI


-- 
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] github-actions[bot] commented on pull request #33839: [SPARK-36291][SQL] Refactor second set of 20 in QueryExecutionErrors to use error classes

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #33839:
URL: https://github.com/apache/spark/pull/33839#issuecomment-1006178618


   We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
   If you'd like to revive this PR, please reopen it and ask a committer to remove the Stale tag!


-- 
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] Peng-Lei commented on a change in pull request #33839: [WIP][SPARK-36291][SQL] Refactor second set of 20 in QueryExecutionErrors to use error classes

Posted by GitBox <gi...@apache.org>.
Peng-Lei commented on a change in pull request #33839:
URL: https://github.com/apache/spark/pull/33839#discussion_r697217253



##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -89,13 +122,31 @@
     "message" : [ "The second argument of '%s' function needs to be an integer." ],
     "sqlState" : "22023"
   },
+  "SHOULD_NOT_CALL_ALIAS_DO_GEN_CODE" : {
+    "message" : [ "Alias.doGenCode should not be called." ]
+  },
+  "SUM_OF_DECIMAL_OVERFLOW" : {
+    "message" : [ "Overflow in sum of decimals." ]
+  },
   "UNABLE_TO_ACQUIRE_MEMORY" : {
     "message" : [ "Unable to acquire %s bytes of memory, got %s" ]
   },
+  "UNEXPECTED_DATATYPE" : {

Review comment:
       Could we try to merge them? 




-- 
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] github-actions[bot] closed pull request #33839: [SPARK-36291][SQL] Refactor second set of 20 in QueryExecutionErrors to use error classes

Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed pull request #33839:
URL: https://github.com/apache/spark/pull/33839


   


-- 
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] HyukjinKwon commented on pull request #33839: [SPARK-36291][SQL] Refactor second set of 20 in QueryExecutionErrors to use error classes

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


   @dgd-contributor, please contact me or private@spark.apache.org. As I shared in the email, the submissions from the specific shared account will not be accepted for now.


-- 
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 #33839: [SPARK-36291][SQL] refactor second set of 20 in QueryExecutionErrors to use error classes

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


   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] Peng-Lei commented on pull request #33839: [WIP][SPARK-36291][SQL] Refactor second set of 20 in QueryExecutionErrors to use error classes

Posted by GitBox <gi...@apache.org>.
Peng-Lei commented on pull request #33839:
URL: https://github.com/apache/spark/pull/33839#issuecomment-906993520


   There is no suitable SQLSTATE for all error class added newly ?


-- 
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 #33839: [SPARK-36291][SQL] Refactor second set of 20 in QueryExecutionErrors to use error classes

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



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala
##########
@@ -170,90 +170,90 @@ object QueryExecutionErrors {
   }
 
   def inputTypeUnsupportedError(dataType: DataType): Throwable = {
-    new IllegalArgumentException(s"Unsupported input type ${dataType.catalogString}")
+    new SparkIllegalArgumentException("UNSUPPORTED_INPUT_TYPE", Array(dataType.catalogString))
   }
 
   def invalidFractionOfSecondError(): DateTimeException = {
-    new SparkDateTimeException(errorClass = "INVALID_FRACTION_OF_SECOND", Array.empty)

Review comment:
       sorry, just a clean up




-- 
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 #33839: [WIP][SPARK-36291][SQL] Refactor second set of 20 in QueryExecutionErrors to use error classes

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



##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -89,13 +122,31 @@
     "message" : [ "The second argument of '%s' function needs to be an integer." ],
     "sqlState" : "22023"
   },
+  "SHOULD_NOT_CALL_ALIAS_DO_GEN_CODE" : {
+    "message" : [ "Alias.doGenCode should not be called." ]
+  },
+  "SUM_OF_DECIMAL_OVERFLOW" : {
+    "message" : [ "Overflow in sum of decimals." ]
+  },
   "UNABLE_TO_ACQUIRE_MEMORY" : {
     "message" : [ "Unable to acquire %s bytes of memory, got %s" ]
   },
+  "UNEXPECTED_DATATYPE" : {

Review comment:
       can we merge them like
   ```
   "UNEXPECTED" : {
       "message" : [ "Unexpected %s" ],
       "sqlState" : "22000"
   ```
   




-- 
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 edited a comment on pull request #33839: [WIP][SPARK-36291][SQL] Refactor second set of 20 in QueryExecutionErrors to use error classes

Posted by GitBox <gi...@apache.org>.
dgd-contributor edited a comment on pull request #33839:
URL: https://github.com/apache/spark/pull/33839#issuecomment-908084585


   > There is no suitable SQLSTATE for all error class added newly ?
   
   No I haven't working on adding sqlstate, I will add them soon
   


-- 
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 #33839: [WIP][SPARK-36291][SQL] Refactor second set of 20 in QueryExecutionErrors to use error classes

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



##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -6,6 +6,10 @@
   "CONCURRENT_QUERY_ERROR" : {
     "message" : [ "Another instance of this query was just started by a concurrent session." ]
   },
+  "COPY_NULL_FIELD" : {
+    "message" : [ "Do not attempt to copy a null field" ],
+    "sqlState" : "39004"

Review comment:
       This only applies to external routine invocations.

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -32,20 +44,36 @@
   "GROUPING_SIZE_LIMIT_EXCEEDED" : {
     "message" : [ "Grouping sets size cannot be greater than %s" ]
   },
+  "GROUP_INDEX_EXCEED_GROUP_COUNT" : {
+    "message" : [ "Regex group count is %s, but the specified group index is %s" ],
+    "sqlState" : "07009"

Review comment:
       I'm not sure if 07009 is right for group index, it seems to apply to descriptor index. Maybe 42000? 

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -32,20 +44,36 @@
   "GROUPING_SIZE_LIMIT_EXCEEDED" : {
     "message" : [ "Grouping sets size cannot be greater than %s" ]
   },
+  "GROUP_INDEX_EXCEED_GROUP_COUNT" : {
+    "message" : [ "Regex group count is %s, but the specified group index is %s" ],
+    "sqlState" : "07009"
+  },
+  "GROUP_INDEX_LESS_THAN_ZERO" : {
+    "message" : [ "The specified group index cannot be less than zero" ],
+    "sqlState" : "07009"
+  },
   "IF_PARTITION_NOT_EXISTS_UNSUPPORTED" : {
     "message" : [ "Cannot write, IF NOT EXISTS is not supported for table: %s" ]
   },
   "INCOMPARABLE_PIVOT_COLUMN" : {
     "message" : [ "Invalid pivot column '%s'. Pivot columns must be comparable." ],
     "sqlState" : "42000"
   },
+  "INCOMPARABLE_TYPE" : {
+    "message" : [ "cannot generate %s code for un-comparable type: %s" ],
+    "sqlState" : "07006"

Review comment:
       0A000 may be a better fit

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -57,6 +85,10 @@
   "INVALID_JSON_SCHEMA_MAPTYPE" : {
     "message" : [ "Input schema %s can only contain StringType as a key type for a MapType." ]
   },
+  "INVALID_URL" : {
+    "message" : [ "Find an invalid url string %s" ],
+    "sqlState" : "22000"

Review comment:
       42000 may be a better fit

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -77,6 +109,18 @@
     "message" : [ "PARTITION clause cannot contain a non-partition column name: %s" ],
     "sqlState" : "42000"
   },
+  "NOT_MATCH_FUNCTION_NAME" : {
+    "message" : [ "%s is not matched at addNewFunction" ],
+    "sqlState" : "07000"
+  },
+  "NOT_SUPPORT_ORDERED_OPERATIONS" : {
+    "message" : [ "Type %s does not support ordered operations" ],
+    "sqlState" : "07006"

Review comment:
       0A000 may be a better fit

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -77,6 +109,18 @@
     "message" : [ "PARTITION clause cannot contain a non-partition column name: %s" ],
     "sqlState" : "42000"
   },
+  "NOT_MATCH_FUNCTION_NAME" : {
+    "message" : [ "%s is not matched at addNewFunction" ],
+    "sqlState" : "07000"
+  },
+  "NOT_SUPPORT_ORDERED_OPERATIONS" : {

Review comment:
       Can we name this `UNSUPPORTED_ORDERED_OPERATIONS`?

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -14,13 +18,21 @@
     "message" : [ "Found duplicate keys '%s'" ],
     "sqlState" : "23000"
   },
+  "EXCEED_ARRAY_SIZE_WHEN_ZIP_MAP" : {
+    "message" : [ "Unsuccessful try to zip maps with %s unique keys due to exceeding the array size limit %s." ],
+    "sqlState" : "22026"

Review comment:
       We can leave this blank for now; I don't see an obvious SQLSTATE for exceeding the array size limit (22026 is only for string data).

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -104,6 +172,10 @@
     "message" : [ "The target JDBC server does not support transaction and can only support ALTER TABLE with a single action." ],
     "sqlState" : "0A000"
   },
+  "WINDOW_NOT_SUPPORT_MERGING" : {

Review comment:
       This doesn't make sense grammatically; can we rephrase it along the lines of "MERGE_UNSUPPORTED_BY_WINDOW_FUNCTIONS"?

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -32,20 +44,36 @@
   "GROUPING_SIZE_LIMIT_EXCEEDED" : {
     "message" : [ "Grouping sets size cannot be greater than %s" ]
   },
+  "GROUP_INDEX_EXCEED_GROUP_COUNT" : {
+    "message" : [ "Regex group count is %s, but the specified group index is %s" ],
+    "sqlState" : "07009"
+  },
+  "GROUP_INDEX_LESS_THAN_ZERO" : {
+    "message" : [ "The specified group index cannot be less than zero" ],
+    "sqlState" : "07009"
+  },
   "IF_PARTITION_NOT_EXISTS_UNSUPPORTED" : {
     "message" : [ "Cannot write, IF NOT EXISTS is not supported for table: %s" ]
   },
   "INCOMPARABLE_PIVOT_COLUMN" : {
     "message" : [ "Invalid pivot column '%s'. Pivot columns must be comparable." ],
     "sqlState" : "42000"
   },
+  "INCOMPARABLE_TYPE" : {

Review comment:
       I think this should be more specific; eg. `CANNOT_GENERATE_CODE_FOR_UNCOMPARABLE_TYPE`.

##########
File path: core/src/main/scala/org/apache/spark/SparkException.scala
##########
@@ -224,3 +224,70 @@ class SparkSQLFeatureNotSupportedException(errorClass: String, messageParameters
   override def getErrorClass: String = errorClass
   override def getSqlState: String = SparkThrowableHelper.getSqlState(errorClass)
 }
+
+/**
+ * Unsupported operation exception thrown from Spark with an error class.
+ */
+class SparkUnsupportedOperationException(errorClass: String, messageParameters: Array[String])

Review comment:
       These should be package-private, eg. https://github.com/apache/spark/blob/f78d8394dcf19891141e353ea3b6a76020faf844/core/src/main/scala/org/apache/spark/SparkException.scala#L221.

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -89,13 +122,31 @@
     "message" : [ "The second argument of '%s' function needs to be an integer." ],
     "sqlState" : "22023"
   },
+  "SHOULD_NOT_CALL_ALIAS_DO_GEN_CODE" : {
+    "message" : [ "Alias.doGenCode should not be called." ]
+  },
+  "SUM_OF_DECIMAL_OVERFLOW" : {
+    "message" : [ "Overflow in sum of decimals." ]
+  },
   "UNABLE_TO_ACQUIRE_MEMORY" : {
     "message" : [ "Unable to acquire %s bytes of memory, got %s" ]
   },
+  "UNEXPECTED_DATATYPE" : {

Review comment:
       I also think 42000 may be a better fit.

##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala
##########
@@ -153,90 +153,88 @@ object QueryExecutionErrors {
   }
 
   def inputTypeUnsupportedError(dataType: DataType): Throwable = {
-    new IllegalArgumentException(s"Unsupported input type ${dataType.catalogString}")
+    new SparkIllegalArgumentException("UNSUPPORTED_INPUT_TYPE", Array(dataType.catalogString))
   }
 
   def invalidFractionOfSecondError(): DateTimeException = {
-    new SparkDateTimeException(errorClass = "INVALID_FRACTION_OF_SECOND", Array.empty)
+    new SparkDateTimeException("INVALID_FRACTION_OF_SECOND", Array.empty)
   }
 
   def overflowInSumOfDecimalError(): ArithmeticException = {
-    new ArithmeticException("Overflow in sum of decimals.")
+    new SparkArithmeticException("SUM_OF_DECIMAL_OVERFLOW", Array.empty)
   }
 
   def overflowInIntegralDivideError(): ArithmeticException = {
-    new ArithmeticException("Overflow in integral divide.")
+    new SparkArithmeticException("INTEGRAL_DIVIDE_OVERFLOW", Array.empty)
   }
 
   def mapSizeExceedArraySizeWhenZipMapError(size: Int): RuntimeException = {
-    new RuntimeException(s"Unsuccessful try to zip maps with $size " +
-      "unique keys due to exceeding the array size limit " +
-      s"${ByteArrayMethods.MAX_ROUNDED_ARRAY_LENGTH}.")
+    new SparkRuntimeException("EXCEED_ARRAY_SIZE_WHEN_ZIP_MAP",
+      Array(size.toString, ByteArrayMethods.MAX_ROUNDED_ARRAY_LENGTH.toString))
   }
 
   def copyNullFieldNotAllowedError(): Throwable = {
-    new IllegalStateException("Do not attempt to copy a null field")
+    new SparkIllegalStateException("COPY_NULL_FIELD", Array.empty)
   }
 
   def literalTypeUnsupportedError(v: Any): RuntimeException = {
-    new SparkRuntimeException("UNSUPPORTED_LITERAL_TYPE",
-      Array(v.getClass.toString, v.toString))
+    new SparkRuntimeException("UNSUPPORTED_LITERAL_TYPE", Array(v.getClass.toString, v.toString))
   }
 
   def noDefaultForDataTypeError(dataType: DataType): RuntimeException = {
-    new RuntimeException(s"no default for type $dataType")
+    new SparkRuntimeException("NO_DEFAULT_FOR_TYPE", Array(dataType.toString))
   }
 
   def doGenCodeOfAliasShouldNotBeCalledError(): Throwable = {
-    new IllegalStateException("Alias.doGenCode should not be called.")
+    new SparkIllegalStateException("SHOULD_NOT_CALL_ALIAS_DO_GEN_CODE", Array.empty)
   }
 
   def orderedOperationUnsupportedByDataTypeError(dataType: DataType): Throwable = {
-    new IllegalArgumentException(s"Type $dataType does not support ordered operations")
+    new SparkIllegalArgumentException("NOT_SUPPORT_ORDERED_OPERATIONS", Array(dataType.toString))
   }
 
   def regexGroupIndexLessThanZeroError(): Throwable = {
-    new IllegalArgumentException("The specified group index cannot be less than zero")
+    new SparkIllegalArgumentException("GROUP_INDEX_LESS_THAN_ZERO", Array.empty)
   }
 
   def regexGroupIndexExceedGroupCountError(
       groupCount: Int, groupIndex: Int): Throwable = {
-    new IllegalArgumentException(
-      s"Regex group count is $groupCount, but the specified group index is $groupIndex")
+    new SparkIllegalArgumentException("GROUP_INDEX_EXCEED_GROUP_COUNT",
+      Array(groupCount.toString, groupIndex.toString))
   }
 
   def invalidUrlError(url: UTF8String, e: URISyntaxException): Throwable = {
-    new IllegalArgumentException(s"Find an invaild url string ${url.toString}", e)
+    new SparkIllegalArgumentException("INVALID_URL", Array(url.toString), cause = e)
   }
 
   def dataTypeOperationUnsupportedError(): Throwable = {
-    new UnsupportedOperationException("dataType")
+    new SparkUnsupportedOperationException("UNSUPPORTED_DATATYPE", Array.empty)
   }
 
   def mergeUnsupportedByWindowFunctionError(): Throwable = {
-    new UnsupportedOperationException("Window Functions do not support merging.")
+    new SparkUnsupportedOperationException("WINDOW_NOT_SUPPORT_MERGING", Array.empty)
   }
 
   def dataTypeUnexpectedError(dataType: DataType): Throwable = {
-    new UnsupportedOperationException(s"Unexpected data type ${dataType.catalogString}")
+    new SparkUnsupportedOperationException("UNEXPECTED_DATATYPE", Array(dataType.catalogString))
   }
 
   def typeUnsupportedError(dataType: DataType): Throwable = {
-    new IllegalArgumentException(s"Unexpected type $dataType")
+    new SparkIllegalArgumentException("UNEXPECTED_TYPE", Array(dataType.toString))
   }
 
   def negativeValueUnexpectedError(frequencyExpression : Expression): Throwable = {
-    new SparkException(s"Negative values found in ${frequencyExpression.sql}")
+    new SparkException(errorClass = "FOUND_NEGATIVE_VALUES",
+      messageParameters = Array(frequencyExpression.sql), cause = null)
   }
 
   def addNewFunctionMismatchedWithFunctionError(funcName: String): Throwable = {
-    new IllegalArgumentException(s"$funcName is not matched at addNewFunction")
+    new SparkIllegalArgumentException("NOT_MATCH_FUNCTION_NAME", Array(funcName))
   }
 
-  def cannotGenerateCodeForUncomparableTypeError(
+  def cannotGenerateCodeForIncomparableTypeError(

Review comment:
       "Uncomparable" is more accurate than "incomparable": "incomparable" (although more commonly used) generally refers to something that is much better than the others, while "uncomparable" refers to something that cannot be compared to others.

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -89,13 +133,37 @@
     "message" : [ "The second argument of '%s' function needs to be an integer." ],
     "sqlState" : "22023"
   },
+  "SHOULD_NOT_CALL_ALIAS_DO_GEN_CODE" : {
+    "message" : [ "Alias.doGenCode should not be called." ],
+    "sqlState" : "42000"

Review comment:
       We can leave this blank; this is an internal error.

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -89,13 +133,37 @@
     "message" : [ "The second argument of '%s' function needs to be an integer." ],
     "sqlState" : "22023"
   },
+  "SHOULD_NOT_CALL_ALIAS_DO_GEN_CODE" : {
+    "message" : [ "Alias.doGenCode should not be called." ],
+    "sqlState" : "42000"
+  },
+  "SUM_OF_DECIMAL_OVERFLOW" : {
+    "message" : [ "Overflow in sum of decimals." ],
+    "sqlState" : "22015"

Review comment:
       22015 is for interval fields; maybe 22003 is a better fit?

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -89,13 +122,31 @@
     "message" : [ "The second argument of '%s' function needs to be an integer." ],
     "sqlState" : "22023"
   },
+  "SHOULD_NOT_CALL_ALIAS_DO_GEN_CODE" : {
+    "message" : [ "Alias.doGenCode should not be called." ]
+  },
+  "SUM_OF_DECIMAL_OVERFLOW" : {
+    "message" : [ "Overflow in sum of decimals." ]
+  },
   "UNABLE_TO_ACQUIRE_MEMORY" : {
     "message" : [ "Unable to acquire %s bytes of memory, got %s" ]
   },
+  "UNEXPECTED_DATATYPE" : {

Review comment:
       I think it makes sense to just keep one or the other; maybe `UNEXPECTED_TYPE`?

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -77,6 +109,18 @@
     "message" : [ "PARTITION clause cannot contain a non-partition column name: %s" ],
     "sqlState" : "42000"
   },
+  "NOT_MATCH_FUNCTION_NAME" : {
+    "message" : [ "%s is not matched at addNewFunction" ],
+    "sqlState" : "07000"

Review comment:
       42000 may be a better fit




-- 
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] HyukjinKwon commented on pull request #33839: [SPARK-36291][SQL] Refactor second set of 20 in QueryExecutionErrors to use error classes

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


   @dgd-contributor, BTW, I think we shouldn't use one account shared to many people because:
   1. it is ambiguous who reviewers communicate w/, e.g.) reviewers asked one thing to fix in a PR but other PRs still have the same mistakes
   2. it is unclear who's the main contributor in the change
   
   I sent an email to the address in GitHub profile but I haven't got a reply yet. Would you mind contacting me via @gurwls223@apache.org?


-- 
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 #33839: [SPARK-36291][SQL] Refactor second set of 20 in QueryExecutionErrors to use error classes

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



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala
##########
@@ -170,90 +170,90 @@ object QueryExecutionErrors {
   }
 
   def inputTypeUnsupportedError(dataType: DataType): Throwable = {
-    new IllegalArgumentException(s"Unsupported input type ${dataType.catalogString}")
+    new SparkIllegalArgumentException("UNSUPPORTED_INPUT_TYPE", Array(dataType.catalogString))
   }
 
   def invalidFractionOfSecondError(): DateTimeException = {
-    new SparkDateTimeException(errorClass = "INVALID_FRACTION_OF_SECOND", Array.empty)

Review comment:
       Why was this changed?




-- 
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] HyukjinKwon edited a comment on pull request #33839: [SPARK-36291][SQL] Refactor second set of 20 in QueryExecutionErrors to use error classes

Posted by GitBox <gi...@apache.org>.
HyukjinKwon edited a comment on pull request #33839:
URL: https://github.com/apache/spark/pull/33839#issuecomment-925450173


   @dgd-contributor, BTW, I think we shouldn't use one account shared to many people because:
   1. it is ambiguous who reviewers communicate w/, e.g.) reviewers asked one thing to fix in a PR but other PRs still have the same mistakes
   2. it is unclear who's the main contributor in the change
   
   I sent an email to the address in GitHub profile but I haven't got a reply yet. Would you mind contacting me via gurwls223@apache.org?


-- 
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 #33839: [WIP][SPARK-36291][SQL] Refactor second set of 20 in QueryExecutionErrors to use error classes

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


   @karenfeng Can you re-review, I've resolve conflict and what you suggested


-- 
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 #33839: [SPARK-36291][SQL] Refactor second set of 20 in QueryExecutionErrors to use error classes

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



##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -60,6 +70,14 @@
   "GROUPING_SIZE_LIMIT_EXCEEDED" : {
     "message" : [ "Grouping sets size cannot be greater than %s" ]
   },
+  "GROUP_INDEX_EXCEED_GROUP_COUNT" : {

Review comment:
       Nit: EXCEED -> EXCEEDS




-- 
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 #33839: [SPARK-36291][SQL] Refactor second set of 20 in QueryExecutionErrors to use error classes

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


   > @dgd-contributor, please contact me or [private@spark.apache.org](mailto:private@spark.apache.org). As I shared in the email, the submissions from the specific shared account will not be accepted for now.
   
   Could  you please check mail from ncthanh.work@gmail.com? Sorry for the inconvenience because the email from your side has been blocked by our mail system.


-- 
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] HyukjinKwon edited a comment on pull request #33839: [SPARK-36291][SQL] Refactor second set of 20 in QueryExecutionErrors to use error classes

Posted by GitBox <gi...@apache.org>.
HyukjinKwon edited a comment on pull request #33839:
URL: https://github.com/apache/spark/pull/33839#issuecomment-925450173


   @dgd-contributor, BTW, I think we shouldn't use one account shared to many people because:
   1. it is ambiguous who reviewers communicate w/, e.g.) reviewers asked one thing to fix in a PR but other PRs still have the same mistakes
   2. it is unclear who's the main contributor in the change
   
   I sent an email to the address in your GitHub profile but I haven't got a reply yet. Would you mind contacting me via gurwls223@apache.org?


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