[SPARK-36292][SQL] Refactor third set of 20 in QueryExecutionErrors to use error classes#33863
[SPARK-36292][SQL] Refactor third set of 20 in QueryExecutionErrors to use error classes#33863dgd-contributor wants to merge 9 commits intoapache:masterfrom
Conversation
|
Can one of the admins verify this patch? |
|
cc @karenfeng FYI |
karenfeng
left a comment
There was a problem hiding this comment.
Thanks for working on this @dgd-contributor! I left some comments.
| }, | ||
| "CLASS_UNSUPPORTED_BY_MAP_OBJECTS" : { | ||
| "message" : [ "Class `%s` is not supported by `MapObjects` as resulting collection." ], | ||
| "sqlState" : "42000" |
There was a problem hiding this comment.
0A000 may be a better fit here.
| "FAILED_SET_ORIGINAL_PERMISSION_BACK" : { | ||
| "message" : [ "Failed to set original permission %s back to the created path: %s. Exception: %s" ] | ||
| }, | ||
| "FAIL_TO_CONVERT_VALUE_TO_JSON" : { |
There was a problem hiding this comment.
For consistency: FAIL -> FAILED?
| "sqlState" : "22023" | ||
| }, | ||
| "RESOLVE_CANNOT_HANDLE_NESTED_SCHEMA" : { | ||
| "message" : [ "Can not handle nested schema yet... plan %s" ], |
There was a problem hiding this comment.
We should avoid making promises about future support. Can you remove yet?
| "message" : [ "Unable to acquire %s bytes of memory, got %s" ] | ||
| }, | ||
| "UNEXPECTED_OPERATOR_IN_CORRELATED_SUBQUERY" : { | ||
| "message" : [ "Unexpected operator %s in correlated subquery%s" ], |
There was a problem hiding this comment.
Nit: there should be a space between subquery and %s
| "sqlState" : "42000" | ||
| }, | ||
| "UNREACHABLE" : { | ||
| "message" : [ "This line should be unreachable%s" ], |
There was a problem hiding this comment.
Nit: there should be a space between unreachable and %s
| "sqlState" : "42000" | ||
| }, | ||
| "UNSUPPORTED_ENCODER" : { | ||
| "message" : [ "Only expression encoders are supported for now." ], |
There was a problem hiding this comment.
We should avoid making promises about future support. Can you remove for now?
| }, | ||
| "UNSUPPORTED_ENCODER" : { | ||
| "message" : [ "Only expression encoders are supported for now." ], | ||
| "sqlState" : "42000" |
There was a problem hiding this comment.
0A000 may be a better fit for all "unsupported" errors.
| }, | ||
| "UNSUPPORTED_NATURAL_JOIN_TYPE" : { | ||
| "message" : [ "Unsupported natural join type %s" ], | ||
| "sqlState" : "42000" |
There was a problem hiding this comment.
0A000 may be a better fit for all "unsupported" errors.
| /** | ||
| * Unsupported operation exception thrown from Spark with an error class. | ||
| */ | ||
| class SparkUnsupportedOperationException(errorClass: String, messageParameters: Array[String]) |
There was a problem hiding this comment.
We should make these classes package-private, eg.
karenfeng
left a comment
There was a problem hiding this comment.
Thanks for working on this @dgd-contributor! I left some comments, please tag me when you address them.
| }, | ||
| "FAILED_TO_CONVERT_VALUE_TO_JSON" : { | ||
| "message" : [ "Failed to convert value %s (class of %s) with the type of %s to JSON." ], | ||
| "sqlState" : "42000" |
There was a problem hiding this comment.
22005 may be a better fit here.
| @@ -55,7 +83,12 @@ | |||
| "sqlState" : "22023" | |||
| }, | |||
| "INVALID_JSON_SCHEMA_MAPTYPE" : { | |||
There was a problem hiding this comment.
While we're here, can you also update: INVALID_JSON_SCHEMA_MAPTYPE -> INVALID_JSON_MAP_KEY_TYPE? The original class name is not very descriptive.
| "message" : [ "Input schema %s can only contain StringType as a key type for a MapType." ], | ||
| "sqlState" : "42000" | ||
| }, | ||
| "METHOD_NOT_DECLARED" : { |
There was a problem hiding this comment.
I don't think this is used? It's also already defined as MISSING_METHOD.
| "message" : [ "PARTITION clause cannot contain a non-partition column name: %s" ], | ||
| "sqlState" : "42000" | ||
| }, | ||
| "NOT_EXPECTED_UNRESOLVED_ENCODER" : { |
There was a problem hiding this comment.
NOT_EXPECTED_UNRESOLVED_ENCODER -> UNEXPECTED_UNRESOLVED_ENCODER
| }, | ||
| "NOT_EXPECTED_UNRESOLVED_ENCODER" : { | ||
| "message" : [ "Unresolved encoder expected, but %s was found." ], | ||
| "sqlState" : "42000" |
There was a problem hiding this comment.
This looks like an internal error, let's remove the SQLSTATE.
| }, | ||
| "RESOLVE_CANNOT_HANDLE_NESTED_SCHEMA" : { | ||
| "message" : [ "Can not handle nested schema... plan %s" ], | ||
| "sqlState" : "42000" |
There was a problem hiding this comment.
This looks like an internal error, let's remove the SQLSTATE.
| "message" : [ "Failed to rename as %s was not found" ], | ||
| "sqlState" : "22023" | ||
| }, | ||
| "RESOLVE_CANNOT_HANDLE_NESTED_SCHEMA" : { |
There was a problem hiding this comment.
RESOLVE_CANNOT_HANDLE_NESTED_SCHEMA -> CANNOT_RESOLVE_NESTED_SCHEMA
| }, | ||
| "UNREACHABLE" : { | ||
| "message" : [ "This line should be unreachable %s" ], | ||
| "sqlState" : "42000" |
There was a problem hiding this comment.
This looks like an internal error, let's remove the SQLSTATE.
| "message" : [ "Unexpected operator %s in correlated subquery %s" ], | ||
| "sqlState" : "42000" | ||
| }, | ||
| "UNREACHABLE" : { |
There was a problem hiding this comment.
UNREACHABLE -> REACHED_UNREACHABLE_LINE - we should provide more detail
| "message" : [ "Unsupported natural join type %s" ], | ||
| "sqlState" : "0A000" | ||
| }, | ||
| "UNSUPPORTED_OPERATION_NOT_RESOLVED" : { |
There was a problem hiding this comment.
UNSUPPORTED_OPERATION_NOT_RESOLVED -> NOT_RESOLVED
|
cc @karenfeng, can you pls review it again? |
karenfeng
left a comment
There was a problem hiding this comment.
I left a few more comments. Thanks for working on this @dgd-contributor, please ping me when you've addressed them.
| }, | ||
| "CANNOT_GENERATE_CODE_FOR_UNSUPPORTED_TYPE" : { | ||
| "message" : [ "Cannot generate code for unsupported type: %s" ], | ||
| "sqlState" : "42000" |
There was a problem hiding this comment.
This should be 0A000 (unsupported)
| }, | ||
| "PRIMARY_CONSTRUCTOR_NOT_FOUND" : { | ||
| "message" : [ "Couldn't find a primary constructor on %s" ], | ||
| "sqlState" : "42000" |
| "message" : [ "Failed to rename as %s was not found" ], | ||
| "sqlState" : "22023" | ||
| }, | ||
| "RESOLVE_CANNOT_HANDLE_NESTED_SCHEMA" : { |
| "message" : [ "Unsupported natural join type %s" ], | ||
| "sqlState" : "0A000" | ||
| }, | ||
| "UNSUPPORTED_ROUNDING" : { |
There was a problem hiding this comment.
UNSUPPORTED_ROUNDING -> UNSUPPORTED_ROUNDING_MODE
| "message" : [ "Unexpected operator %s in correlated subquery %s" ], | ||
| "sqlState" : "42000" | ||
| }, | ||
| "UNEXPECTED_UNRESOLVED_ENCODER" : { |
There was a problem hiding this comment.
Whoops, I meant: UNEXPECTED_UNRESOLVED_ENCODER -> EXPECTED_UNRESOLVED_ENCODER
| "message" : [ "PARTITION clause cannot contain a non-partition column name: %s" ], | ||
| "sqlState" : "42000" | ||
| }, | ||
| "NOT_RESOLVED" : { |
There was a problem hiding this comment.
In retrospect, this is specific to custom collection class resolution. Can we make this class name more specific? Eg. CUSTOM_COLLECTION_CLASS_NOT_RESOLVED
| "message" : [ "Failed to convert value %s (class of %s) with the type of %s to JSON." ], | ||
| "sqlState" : "22005" | ||
| }, | ||
| "FIELD_CANNOT_BE_NULL" : { |
There was a problem hiding this comment.
Let's make this more specific: ROW_FIELD_CANNOT_BE_NULL
|
Thank you for your review, @karenfeng. As we and @HyukjinKwon discussed contributing by sharing accounts, we will close this PR, and recreate this one with an individual account. We will also update the code with your comments. |
What changes were proposed in this pull request?
Refactor some exceptions in QueryExecutionErrors to use error classes.
Why are the changes needed?
There are currently ~350 exceptions in this file; so this PR only focuses on the third set of 20.
Does this PR introduce any user-facing change?
No
How was this patch tested?
Existed UT Testcase