Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-40360] ALREADY_EXISTS and NOT_FOUND exceptions
### What changes were proposed in this pull request? This PR introduces the following error classes: - PARTITIONS_ALREADY_EXIST Cannot ADD or RENAME TO partition(s) <partitionList> in table <tableName> because they already exist. Choose a different name, drop the existing partition, or add the IF NOT EXISTS clause to tolerate a pre-existing partition - PARTITIONS_NOT_FOUND The partition(s) <partitionList> cannot be found in table <tableName>. Verify the partition specification and table name. To tolerate the error on drop use ALTER TABLE … DROP IF EXISTS PARTITION. - ROUTINE_ALREADY_EXISTS Cannot create the function <routineName> because it already exists. Choose a different name, drop or replace the existing function, or add the IF NOT EXISTS clause to tolerate a pre-existing function - ROUTINE_NOT_FOUND The function <routineName> cannot be found. Verify the spelling and correctness of the schema and catalog. If you did not qualify the name with a schema and catalog, verify the current_schema() output, or qualify the name with the correct schema and catalog. To tolerate the error on drop use DROP FUNCTION IF EXISTS - SCHEMA_ALREADY_EXISTS Cannot create schema <schemaName> because it already exists. Choose a different name, drop the existing schema, or add the IF NOT EXISTS clause to tolerate pre-existing schema - SCHEMA_NOT_EMPTY Cannot drop a schema <schemaName> because it contains objects. Use DROP SCHEMA ... CASCADE to drop the schema and all its objects. - SCHEMA_NOT_FOUND The schema <schemaName> cannot be found. Verify the spelling and correctness of the schema and catalog. If you did not qualify the name with a catalog, verify the current_schema() output, or qualify the name with the correct catalog. To tolerate the error on drop use DROP SCHEMA IF EXISTS. - TABLE_OR_VIEW_ALREADY_EXISTS Cannot create table or view <relationName> because it already exists. Choose a different name, drop or replace the existing object, or add the IF NOT EXISTS clause to tolerate pre-existing objects - TABLE_OR_VIEW_NOT_FOUND The table or view <relationName> cannot be found. Verify the spelling and correctness of the schema and catalog. If you did not qualify the name with a schema, verify the current_schema() output, or qualify the name with the correct schema and catalog. To tolerate the error on drop use DROP VIEW IF EXISTS or DROP TABLE IF EXISTS. - TEMP_TABLE_OR_VIEW_ALREADY_EXISTS Cannot create the temporary view <relationName> because it already exists. Choose a different name, drop or replace the existing view, or add the IF NOT EXISTS clause to tolerate pre-existing views. Also (for JDBC data sources): - INDEX_ALREADY_EXISTS Cannot create the index because it already exists. <message>. - INDEX_NOT_FOUND Cannot find the index. <message>. Some background: * We use ROUTINE over FUNCTION to be future proof, if/when PROCEDUREs appear. * We coarsify around TABLE_OR_VIEW_NOT_FOUND and TABLE_OR_VIEW_ALREADY_EXISTS (getting rid of dedicated reason as RENAME TABLE, etc. * We combine PARTITION and PARTITIONS errors * I use SCHEMA religiously. A debate can be had whether/ho/when to return NAMESPACE There is currently one failure caused by: https://issues.apache.org/jira/browse/SPARK-40521 Hive based ALTER TABLE ADD PARTITION returns to many partitions in case of PARTITIONS_ALREADY_EXISTS. ### Why are the changes needed? We want to convert all error to use the error-class framework ### Does this PR introduce _any_ user-facing change? Yes, we are moving away from "free txt" and consolidate errors is error-classes.json. This hardens the QA and code allowing us to improve error messages without breaking changes ### How was this patch tested? Run existing QA suite Closes #37887 from srielau/SPARK-40360-Convert-some-ddl-mesages. Authored-by: Serge Rielau <serge.rielau@databricks.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
- Loading branch information