-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-37636][SQL][FOLLOW-UP] Move handling Hive exceptions for create/drop database to HiveClientImpl #35173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-37636][SQL][FOLLOW-UP] Move handling Hive exceptions for create/drop database to HiveClientImpl #35173
Conversation
| client.dropDatabase(db, ignoreIfNotExists, cascade) | ||
| } { exception => | ||
| if (exception.getClass.getName.equals("org.apache.hadoop.hive.ql.metadata.HiveException") | ||
| && exception.getMessage.contains(s"Database $db is not empty")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cloud-fan Note that I removed . when checking the message.
For Hive 0.12, the exception message is InvalidOperationException(message:Database temporary is not empty), whereas for Hive >0.12, the message is [InvalidOperationException(message:Database temporary is not empty. One or more tables exist.)]. So the wrapping wasn't working for Hive 0.12.
sql/hive/src/test/scala/org/apache/spark/sql/hive/client/VersionsSuite.scala
Outdated
Show resolved
Hide resolved
| case Some(wrapped) => throw wrapped | ||
| case None => throw new AnalysisException( | ||
| e.getClass.getCanonicalName + ": " + e.getMessage, cause = Some(e)) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is reverting changes made in #35113.
| shim.createDatabase(client, hiveDb, ignoreIfExists) | ||
| } catch { | ||
| case _: AlreadyExistsException => | ||
| throw new DatabaseAlreadyExistsException(database.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if we need to do something similar as:
spark/sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala
Lines 607 to 612 in 17aaf8e
| try { | |
| shim.createPartitions(client, db, table, parts, ignoreIfExists) | |
| } catch { | |
| case e: InvocationTargetException => replaceExistException(e.getCause) | |
| case e: Throwable => replaceExistException(e) | |
| } |
@MaxGekk do you happen to know?
| shim.dropDatabase(client, name, true, ignoreIfNotExists, cascade) | ||
| } catch { | ||
| case e: HiveException if e.getMessage.contains(s"Database $name is not empty") => | ||
| throw QueryCompilationErrors.cannotDropNonemptyDatabaseError(name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
|
@cloud-fan is this ready to be merged? |
|
thanks, merging to master! |
…e/drop database to HiveClientImpl ### What changes were proposed in this pull request? apache#35113 introduced `HiveExternalCatalog.withClientWrappingException` to to wrap a Hive exception to a Spark exception. However, there was a limitation of testing it against different Hive versions as outlined in apache#35173 (comment). This PR proposes to revert `HiveExternalCatalog.withClientWrappingException` and move wrapping logic to `HiveClientImpl`. ### Why are the changes needed? 1. To make testing against different Hive versions better. 2. For Hive 0.12, the wrapping logic was not working correctly for `dropDatabase` because the message was not matching. ### Does this PR introduce _any_ user-facing change? Yes, for Hive 0.12, the exception message will now be consistent with other versions. Before: `InvalidOperationException(message:Database db is not empty)` After: `Cannot drop a non-empty database: db. Use CASCADE option to drop a non-empty database` ### How was this patch tested? Added a new test coverage. Closes apache#35173 from imback82/drop_db_withClientWrappingException. Authored-by: Terry Kim <[email protected]> Signed-off-by: Wenchen Fan <[email protected]>
What changes were proposed in this pull request?
#35113 introduced
HiveExternalCatalog.withClientWrappingExceptionto to wrap a Hive exception to a Spark exception. However, there was a limitation of testing it against different Hive versions as outlined in #35173 (comment). This PR proposes to revertHiveExternalCatalog.withClientWrappingExceptionand move wrapping logic toHiveClientImpl.Why are the changes needed?
dropDatabasebecause the message was not matching.Does this PR introduce any user-facing change?
Yes, for Hive 0.12, the exception message will now be consistent with other versions.
Before:
InvalidOperationException(message:Database db is not empty)After:
Cannot drop a non-empty database: db. Use CASCADE option to drop a non-empty databaseHow was this patch tested?
Added a new test coverage.