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



##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -63,5 +63,86 @@
   "WRITING_JOB_ABORTED" : {
     "message" : [ "Writing job aborted" ],
     "sqlState" : "40000"
+  },
+  "INVALID_INSERT_INTO_CONTEXT" : {
+    "message" : [ "Invalid InsertIntoContext" ],
+    "sqlState" : "10001"
+  },
+  "INSERT_OVERWRITE_DIRECTORY_UNSUPPORTED" : {
+    "message" : [ "INSERT OVERWRITE DIRECTORY is not supported" ],

Review comment:
       It'd be cleaner if we parametrized this error message to create a single 
error class representing simple operations that are unsupported in all cases, 
such as `OPERATION_UNSUPPORTED`: `%s is not supported`. Then we can collapse 
this with some of the error classes below.

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -63,5 +63,86 @@
   "WRITING_JOB_ABORTED" : {
     "message" : [ "Writing job aborted" ],
     "sqlState" : "40000"
+  },
+  "INVALID_INSERT_INTO_CONTEXT" : {
+    "message" : [ "Invalid InsertIntoContext" ],
+    "sqlState" : "10001"
+  },
+  "INSERT_OVERWRITE_DIRECTORY_UNSUPPORTED" : {
+    "message" : [ "INSERT OVERWRITE DIRECTORY is not supported" ],
+    "sqlState" : "10002"
+  },
+  "COLUMNS_ALIASES_NOT_ALLOWED_IN_OPERATION" : {
+    "message" : [ "Columns aliases are not allowed in %s." ],
+    "sqlState" : "10003"
+  },
+  "EMPTY_SOURCE_FOR_MERGE" : {
+    "message" : [ "Empty source for merge: you should specify a source 
table/subquery in merge." ],
+    "sqlState" : "10004"
+  },
+  "UNRECOGNIZED_MATCHED_ACTION" : {
+    "message" : [ "Unrecognized matched action: %s" ],
+    "sqlState" : "10005"
+  },
+  "INSERTED_VALUE_NUMBER_NOT_MATCH_FIELD_NUMBER" : {
+    "message" : [ "The number of inserted values cannot match the fields." ],
+    "sqlState" : "10006"
+  },
+  "UNRECOGNIZED_NOT_MATCHED_ACTION" : {
+    "message" : [ "Unrecognized not matched action: %s" ],
+    "sqlState" : "10007"
+  },
+  "MERGE_STATEMENT_WITHOUT_WHEN_CLAUSE" : {
+    "message" : [ "There must be at least one WHEN clause in a MERGE 
statement" ],
+    "sqlState" : "10008"
+  },
+  "NON_LAST_MATCHED_CLAUSE_OMIT_CONDITION" : {

Review comment:
       We can also parametrize these two error messages to simplify auditing.

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -63,5 +63,86 @@
   "WRITING_JOB_ABORTED" : {
     "message" : [ "Writing job aborted" ],
     "sqlState" : "40000"
+  },
+  "INVALID_INSERT_INTO_CONTEXT" : {
+    "message" : [ "Invalid InsertIntoContext" ],
+    "sqlState" : "10001"
+  },
+  "INSERT_OVERWRITE_DIRECTORY_UNSUPPORTED" : {
+    "message" : [ "INSERT OVERWRITE DIRECTORY is not supported" ],
+    "sqlState" : "10002"
+  },
+  "COLUMNS_ALIASES_NOT_ALLOWED_IN_OPERATION" : {
+    "message" : [ "Columns aliases are not allowed in %s." ],
+    "sqlState" : "10003"
+  },
+  "EMPTY_SOURCE_FOR_MERGE" : {
+    "message" : [ "Empty source for merge: you should specify a source 
table/subquery in merge." ],
+    "sqlState" : "10004"
+  },
+  "UNRECOGNIZED_MATCHED_ACTION" : {
+    "message" : [ "Unrecognized matched action: %s" ],
+    "sqlState" : "10005"
+  },
+  "INSERTED_VALUE_NUMBER_NOT_MATCH_FIELD_NUMBER" : {
+    "message" : [ "The number of inserted values cannot match the fields." ],
+    "sqlState" : "10006"
+  },
+  "UNRECOGNIZED_NOT_MATCHED_ACTION" : {
+    "message" : [ "Unrecognized not matched action: %s" ],
+    "sqlState" : "10007"
+  },
+  "MERGE_STATEMENT_WITHOUT_WHEN_CLAUSE" : {
+    "message" : [ "There must be at least one WHEN clause in a MERGE 
statement" ],
+    "sqlState" : "10008"
+  },
+  "NON_LAST_MATCHED_CLAUSE_OMIT_CONDITION" : {
+    "message" : [ "When there are more than one MATCHED clauses in a MERGE 
statement, only the last MATCHED clause can omit the condition." ],
+    "sqlState" : "10009"
+  },
+  "NON_LAST_NOT_MATCHED_CLAUSE_OMIT_CONDITION" : {
+    "message" : [ "When there are more than one NOT MATCHED clauses in a MERGE 
statement, only the last NOT MATCHED clause can omit the condition." ],
+    "sqlState" : "10010"
+  },
+  "EMPTY_PARTITION_KEY" : {
+    "message" : [ "Found an empty partition key '%s'." ],
+    "sqlState" : "10011"
+  },
+  "COMBINATION_QUERY_RESULT_CLAUSES_UNSUPPORTED" : {
+    "message" : [ "Combination of ORDER BY/SORT BY/DISTRIBUTE BY/CLUSTER BY is 
not supported" ],
+    "sqlState" : "10012"
+  },
+  "DISTRIBUTE_BY_UNSUPPORTED" : {
+    "message" : [ "DISTRIBUTE BY is not supported" ],
+    "sqlState" : "10013"
+  },
+  "TRANSFORM_NOT_SUPPORT_QUANTIFIER" : {
+    "message" : [ "TRANSFORM does not support DISTINCT/ALL in inputs" ],
+    "sqlState" : "10014"
+  },
+  "TRANSFORM_WITH_SERDE_UNSUPPORTED" : {
+    "message" : [ "TRANSFORM with serde is only supported in hive mode" ],
+    "sqlState" : "10015"
+  },
+  "LATERAL_WITH_PIVOT_IN_FROM_CLAUSE_NOT_ALLOWED" : {
+    "message" : [ "LATERAL cannot be used together with PIVOT in FROM clause" 
],
+    "sqlState" : "10016"
+  },
+  "LATERAL_JOIN_WITH_NATURAL_JOIN_UNSUPPORTED" : {

Review comment:
       I think we can merge these as well.

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -63,5 +63,86 @@
   "WRITING_JOB_ABORTED" : {
     "message" : [ "Writing job aborted" ],
     "sqlState" : "40000"
+  },
+  "INVALID_INSERT_INTO_CONTEXT" : {
+    "message" : [ "Invalid InsertIntoContext" ],
+    "sqlState" : "10001"
+  },
+  "INSERT_OVERWRITE_DIRECTORY_UNSUPPORTED" : {
+    "message" : [ "INSERT OVERWRITE DIRECTORY is not supported" ],
+    "sqlState" : "10002"
+  },
+  "COLUMNS_ALIASES_NOT_ALLOWED_IN_OPERATION" : {
+    "message" : [ "Columns aliases are not allowed in %s." ],
+    "sqlState" : "10003"
+  },
+  "EMPTY_SOURCE_FOR_MERGE" : {
+    "message" : [ "Empty source for merge: you should specify a source 
table/subquery in merge." ],
+    "sqlState" : "10004"
+  },
+  "UNRECOGNIZED_MATCHED_ACTION" : {

Review comment:
       Can we simplify this by parametrizing? Then we only need one for 
`MATCHED`/`NOT_MATCHED`.

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -63,5 +63,86 @@
   "WRITING_JOB_ABORTED" : {
     "message" : [ "Writing job aborted" ],
     "sqlState" : "40000"
+  },
+  "INVALID_INSERT_INTO_CONTEXT" : {
+    "message" : [ "Invalid InsertIntoContext" ],
+    "sqlState" : "10001"
+  },
+  "INSERT_OVERWRITE_DIRECTORY_UNSUPPORTED" : {
+    "message" : [ "INSERT OVERWRITE DIRECTORY is not supported" ],
+    "sqlState" : "10002"
+  },
+  "COLUMNS_ALIASES_NOT_ALLOWED_IN_OPERATION" : {

Review comment:
       Grammar nit: `Columns aliases` -> `Column aliases`.

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -63,5 +63,86 @@
   "WRITING_JOB_ABORTED" : {
     "message" : [ "Writing job aborted" ],
     "sqlState" : "40000"
+  },
+  "INVALID_INSERT_INTO_CONTEXT" : {
+    "message" : [ "Invalid InsertIntoContext" ],
+    "sqlState" : "10001"

Review comment:
       The SQLSTATEs should reflect those set in the ANSI/ISO standard; see 
https://github.com/apache/spark/blob/master/core/src/main/resources/error/README.md.

##########
File path: core/src/main/resources/error/error-classes.json
##########
@@ -63,5 +63,86 @@
   "WRITING_JOB_ABORTED" : {
     "message" : [ "Writing job aborted" ],
     "sqlState" : "40000"
+  },
+  "INVALID_INSERT_INTO_CONTEXT" : {
+    "message" : [ "Invalid InsertIntoContext" ],
+    "sqlState" : "10001"
+  },
+  "INSERT_OVERWRITE_DIRECTORY_UNSUPPORTED" : {
+    "message" : [ "INSERT OVERWRITE DIRECTORY is not supported" ],
+    "sqlState" : "10002"
+  },
+  "COLUMNS_ALIASES_NOT_ALLOWED_IN_OPERATION" : {
+    "message" : [ "Columns aliases are not allowed in %s." ],
+    "sqlState" : "10003"
+  },
+  "EMPTY_SOURCE_FOR_MERGE" : {
+    "message" : [ "Empty source for merge: you should specify a source 
table/subquery in merge." ],
+    "sqlState" : "10004"
+  },
+  "UNRECOGNIZED_MATCHED_ACTION" : {
+    "message" : [ "Unrecognized matched action: %s" ],
+    "sqlState" : "10005"
+  },
+  "INSERTED_VALUE_NUMBER_NOT_MATCH_FIELD_NUMBER" : {
+    "message" : [ "The number of inserted values cannot match the fields." ],
+    "sqlState" : "10006"
+  },
+  "UNRECOGNIZED_NOT_MATCHED_ACTION" : {
+    "message" : [ "Unrecognized not matched action: %s" ],
+    "sqlState" : "10007"
+  },
+  "MERGE_STATEMENT_WITHOUT_WHEN_CLAUSE" : {
+    "message" : [ "There must be at least one WHEN clause in a MERGE 
statement" ],
+    "sqlState" : "10008"
+  },
+  "NON_LAST_MATCHED_CLAUSE_OMIT_CONDITION" : {
+    "message" : [ "When there are more than one MATCHED clauses in a MERGE 
statement, only the last MATCHED clause can omit the condition." ],
+    "sqlState" : "10009"
+  },
+  "NON_LAST_NOT_MATCHED_CLAUSE_OMIT_CONDITION" : {
+    "message" : [ "When there are more than one NOT MATCHED clauses in a MERGE 
statement, only the last NOT MATCHED clause can omit the condition." ],
+    "sqlState" : "10010"
+  },
+  "EMPTY_PARTITION_KEY" : {
+    "message" : [ "Found an empty partition key '%s'." ],
+    "sqlState" : "10011"
+  },
+  "COMBINATION_QUERY_RESULT_CLAUSES_UNSUPPORTED" : {
+    "message" : [ "Combination of ORDER BY/SORT BY/DISTRIBUTE BY/CLUSTER BY is 
not supported" ],
+    "sqlState" : "10012"
+  },
+  "DISTRIBUTE_BY_UNSUPPORTED" : {
+    "message" : [ "DISTRIBUTE BY is not supported" ],
+    "sqlState" : "10013"
+  },
+  "TRANSFORM_NOT_SUPPORT_QUANTIFIER" : {
+    "message" : [ "TRANSFORM does not support DISTINCT/ALL in inputs" ],
+    "sqlState" : "10014"
+  },
+  "TRANSFORM_WITH_SERDE_UNSUPPORTED" : {
+    "message" : [ "TRANSFORM with serde is only supported in hive mode" ],
+    "sqlState" : "10015"
+  },
+  "LATERAL_WITH_PIVOT_IN_FROM_CLAUSE_NOT_ALLOWED" : {
+    "message" : [ "LATERAL cannot be used together with PIVOT in FROM clause" 
],
+    "sqlState" : "10016"
+  },
+  "LATERAL_JOIN_WITH_NATURAL_JOIN_UNSUPPORTED" : {
+    "message" : [ "LATERAL join with NATURAL join is not supported" ],
+    "sqlState" : "10017"
+  },
+  "LATERAL_JOIN_WITH_USING_JOIN_UNSUPPORTED" : {
+    "message" : [ "LATERAL join with USING join is not supported" ],
+    "sqlState" : "10018"
+  },
+  "UNSUPPORTED_LATERAL_JOIN_TYPE" : {
+    "message" : [ "Unsupported LATERAL join type %s" ],
+    "sqlState" : "10019"
+  },
+  "INVALID_LATERAL_JOIN_RELATION" : {
+    "message" : [ "LATERAL can only be used with subquery" ],
+    "sqlState" : "10020"
   }
-}
\ No newline at end of file
+}

Review comment:
       This newline may be causing the test failures; we guarantee that the 
spacing is correct with a round trip read/write in the unit 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to