Skip to content

Commit

Permalink
HANDLERS + SIGNAL
Browse files Browse the repository at this point in the history
  • Loading branch information
miland-db committed Jan 31, 2025
1 parent 6bbfa2d commit ca6f439
Show file tree
Hide file tree
Showing 23 changed files with 2,217 additions and 103 deletions.
86 changes: 86 additions & 0 deletions common/utils/src/main/resources/error/error-conditions.json
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,30 @@
],
"sqlState" : "42614"
},
"DUPLICATE_CONDITION_IN_SCOPE" : {
"message" : [
"Found duplicate condition <condition> in the scope. Please, remove one of them."
],
"sqlState" : "42734"
},
"DUPLICATE_EXCEPTION_HANDLER" : {
"message" : [
"Found duplicate handlers. Please, remove one of them."
],
"subClass" : {
"CONDITION" : {
"message" : [
"Found duplicate handlers for the same condition <condition>."
]
},
"SQLSTATE" : {
"message" : [
"Found duplicate handlers for the same SQLSTATE <sqlState>."
]
}
},
"sqlState" : "42734"
},
"DUPLICATE_KEY" : {
"message" : [
"Found duplicate keys <keyColumn>."
Expand Down Expand Up @@ -2440,6 +2464,24 @@
],
"sqlState" : "42K05"
},
"INVALID_ERROR_CONDITION_DECLARATION" : {
"message" : [
"Invalid condition declaration."
],
"subClass" : {
"ONLY_AT_BEGINNING" : {
"message" : [
"Condition <conditionName> can only be declared at the beginning of the compound."
]
},
"QUALIFIED_CONDITION_NAME" : {
"message" : [
"Condition <conditionName> cannot be qualified."
]
}
},
"sqlState" : "42K0R"
},
"INVALID_ESC" : {
"message" : [
"Found an invalid escape string: <invalidEscape>. The escape string must contain only one character."
Expand Down Expand Up @@ -2608,6 +2650,39 @@
},
"sqlState" : "HY000"
},
"INVALID_HANDLER_DECLARATION" : {
"message" : [
"Invalid handler declaration."
],
"subClass" : {
"CONDITION_NOT_FOUND" : {
"message" : [
"Condition <condition> not found."
]
},
"DUPLICATE_CONDITION_IN_HANDLER_DECLARATION" : {
"message" : [
"Found duplicate condition <condition> in the handler declaration. Please, remove one of them."
]
},
"DUPLICATE_SQLSTATE_IN_HANDLER_DECLARATION" : {
"message" : [
"Found duplicate sqlState <sqlState> in the handler declaration. Please, remove one of them."
]
},
"INVALID_CONDITION_COMBINATION" : {
"message" : [
"Invalid combination of conditions in the handler declaration. SQLEXCEPTION and NOT FOUND cannot be used together with other condition/sqlstate values."
]
},
"WRONG_PLACE_OF_DECLARATION" : {
"message" : [
"Handlers must be declared after variable/condition declaration, and before other statements."
]
}
},
"sqlState" : "42K0Q"
},
"INVALID_IDENTIFIER" : {
"message" : [
"The unquoted identifier <ident> is invalid and must be back quoted as: `<ident>`.",
Expand Down Expand Up @@ -3264,6 +3339,12 @@
},
"sqlState" : "42616"
},
"INVALID_SQLSTATE" : {
"message" : [
"Invalid SQLSTATE value: '<sqlState>'. SQLSTATE must be exactly 5 characters long and contain only A-Z and 0-9. SQLSTATE must not start with '00', '01', or 'XX'."
],
"sqlState" : "428B3"
},
"INVALID_SQL_ARG" : {
"message" : [
"The argument <name> of `sql()` is invalid. Consider to replace it either by a SQL literal or by collection constructor functions such as `map()`, `array()`, `struct()`."
Expand Down Expand Up @@ -5492,6 +5573,11 @@
"Attach a comment to the namespace <namespace>."
]
},
"CONTINUE_EXCEPTION_HANDLER" : {
"message" : [
"CONTINUE exception handler is not supported. Use EXIT handler."
]
},
"DESC_TABLE_COLUMN_JSON" : {
"message" : [
"DESC TABLE COLUMN AS JSON not supported for individual columns."
Expand Down
12 changes: 12 additions & 0 deletions common/utils/src/main/resources/error/error-states.json
Original file line number Diff line number Diff line change
Expand Up @@ -4643,6 +4643,18 @@
"standard": "N",
"usedBy": ["Spark"]
},
"42K0Q": {
"description": "Invalid handler declaration.",
"origin": "Spark",
"standard": "N",
"usedBy": ["Spark"]
},
"42K0R": {
"description": "Invalid condition declaration.",
"origin": "Spark",
"standard": "N",
"usedBy": ["Spark"]
},
"42KD0": {
"description": "Ambiguous name reference.",
"origin": "Databricks",
Expand Down
8 changes: 8 additions & 0 deletions docs/sql-ref-ansi-compliance.md
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,10 @@ Below is a list of all the keywords in Spark SQL.
|COMPENSATION|non-reserved|non-reserved|non-reserved|
|COMPUTE|non-reserved|non-reserved|non-reserved|
|CONCATENATE|non-reserved|non-reserved|non-reserved|
|CONDITION|non-reserved|non-reserved|non-reserved|
|CONSTRAINT|reserved|non-reserved|reserved|
|CONTAINS|non-reserved|non-reserved|non-reserved|
|CONTINUE|non-reserved|non-reserved|non-reserved|
|COST|non-reserved|non-reserved|non-reserved|
|CREATE|reserved|non-reserved|reserved|
|CROSS|reserved|strict-non-reserved|reserved|
Expand Down Expand Up @@ -512,6 +514,7 @@ Below is a list of all the keywords in Spark SQL.
|EXCLUDE|non-reserved|non-reserved|non-reserved|
|EXECUTE|reserved|non-reserved|reserved|
|EXISTS|non-reserved|non-reserved|reserved|
|EXIT|non-reserved|non-reserved|non-reserved|
|EXPLAIN|non-reserved|non-reserved|non-reserved|
|EXPORT|non-reserved|non-reserved|non-reserved|
|EXTEND|non-reserved|non-reserved|non-reserved|
Expand All @@ -530,6 +533,7 @@ Below is a list of all the keywords in Spark SQL.
|FOREIGN|reserved|non-reserved|reserved|
|FORMAT|non-reserved|non-reserved|non-reserved|
|FORMATTED|non-reserved|non-reserved|non-reserved|
|FOUND|non-reserved|non-reserved|non-reserved|
|FROM|reserved|non-reserved|reserved|
|FULL|reserved|strict-non-reserved|reserved|
|FUNCTION|non-reserved|non-reserved|reserved|
Expand All @@ -539,6 +543,7 @@ Below is a list of all the keywords in Spark SQL.
|GRANT|reserved|non-reserved|reserved|
|GROUP|reserved|non-reserved|reserved|
|GROUPING|non-reserved|non-reserved|reserved|
|HANDLER|non-reserved|non-reserved|non-reserved|
|HAVING|reserved|non-reserved|reserved|
|HOUR|non-reserved|non-reserved|non-reserved|
|HOURS|non-reserved|non-reserved|non-reserved|
Expand Down Expand Up @@ -700,6 +705,8 @@ Below is a list of all the keywords in Spark SQL.
|SOURCE|non-reserved|non-reserved|non-reserved|
|SPECIFIC|non-reserved|non-reserved|reserved|
|SQL|reserved|non-reserved|reserved|
|SQLEXCEPTION|non-reserved|non-reserved|non-reserved|
|SQLSTATE|non-reserved|non-reserved|non-reserved|
|START|non-reserved|non-reserved|reserved|
|STATISTICS|non-reserved|non-reserved|non-reserved|
|STORED|non-reserved|non-reserved|non-reserved|
Expand Down Expand Up @@ -753,6 +760,7 @@ Below is a list of all the keywords in Spark SQL.
|USE|non-reserved|non-reserved|non-reserved|
|USER|reserved|non-reserved|reserved|
|USING|reserved|strict-non-reserved|reserved|
|VALUE|non-reserved|non-reserved|non-reserved|
|VALUES|non-reserved|non-reserved|reserved|
|VARCHAR|non-reserved|non-reserved|reserved|
|VAR|non-reserved|non-reserved|non-reserved|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,10 @@ COMPACTIONS: 'COMPACTIONS';
COMPENSATION: 'COMPENSATION';
COMPUTE: 'COMPUTE';
CONCATENATE: 'CONCATENATE';
CONDITION: 'CONDITION';
CONSTRAINT: 'CONSTRAINT';
CONTAINS: 'CONTAINS';
CONTINUE: 'CONTINUE';
COST: 'COST';
CREATE: 'CREATE';
CROSS: 'CROSS';
Expand Down Expand Up @@ -226,6 +228,7 @@ EXCEPT: 'EXCEPT';
EXCHANGE: 'EXCHANGE';
EXCLUDE: 'EXCLUDE';
EXISTS: 'EXISTS';
EXIT: 'EXIT';
EXPLAIN: 'EXPLAIN';
EXPORT: 'EXPORT';
EXTEND: 'EXTEND';
Expand All @@ -244,6 +247,7 @@ FOR: 'FOR';
FOREIGN: 'FOREIGN';
FORMAT: 'FORMAT';
FORMATTED: 'FORMATTED';
FOUND: 'FOUND';
FROM: 'FROM';
FULL: 'FULL';
FUNCTION: 'FUNCTION';
Expand All @@ -253,6 +257,7 @@ GLOBAL: 'GLOBAL';
GRANT: 'GRANT';
GROUP: 'GROUP';
GROUPING: 'GROUPING';
HANDLER: 'HANDLER';
HAVING: 'HAVING';
BINARY_HEX: 'X';
HOUR: 'HOUR';
Expand Down Expand Up @@ -309,6 +314,7 @@ MACRO: 'MACRO';
MAP: 'MAP' {incComplexTypeLevelCounter();};
MATCHED: 'MATCHED';
MERGE: 'MERGE';
MESSAGE_TEXT: 'MESSAGE_TEXT';
MICROSECOND: 'MICROSECOND';
MICROSECONDS: 'MICROSECONDS';
MILLISECOND: 'MILLISECOND';
Expand Down Expand Up @@ -405,6 +411,7 @@ SETMINUS: 'MINUS';
SETS: 'SETS';
SHORT: 'SHORT';
SHOW: 'SHOW';
SIGNAL: 'SIGNAL';
SINGLE: 'SINGLE';
SKEWED: 'SKEWED';
SMALLINT: 'SMALLINT';
Expand All @@ -414,6 +421,8 @@ SORTED: 'SORTED';
SOURCE: 'SOURCE';
SPECIFIC: 'SPECIFIC';
SQL: 'SQL';
SQLEXCEPTION: 'SQLEXCEPTION';
SQLSTATE: 'SQLSTATE';
START: 'START';
STATISTICS: 'STATISTICS';
STORED: 'STORED';
Expand Down Expand Up @@ -467,6 +476,7 @@ UPDATE: 'UPDATE';
USE: 'USE';
USER: 'USER';
USING: 'USING';
VALUE: 'VALUE';
VALUES: 'VALUES';
VARCHAR: 'VARCHAR';
VAR: 'VAR';
Expand Down
Loading

0 comments on commit ca6f439

Please sign in to comment.