-
Notifications
You must be signed in to change notification settings - Fork 919
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
[KSHC] Unify the exception handling of v1 and v2 during dropDatabase #5225
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5225 +/- ##
======================================
Coverage 0.00% 0.00%
======================================
Files 589 589
Lines 33311 33307 -4
Branches 4399 4397 -2
======================================
+ Misses 33311 33307 -4
... and 3 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
LGTM. It also helps for resolving the blocker issue for enabling tests on Scala 2.13 in the future, as discovered and discussed in #5196.
val e = intercept[IllegalStateException] { | ||
val e = intercept[AnalysisException] { | ||
sql(s"DROP NAMESPACE $catalogName.$namespace") | ||
} | ||
assert(e.getMessage.contains(s"Namespace $namespace is not empty")) | ||
if (SPARK_RUNTIME_VERSION >= "3.4") { | ||
assert(e.getMessage().contains( | ||
s"[SCHEMA_NOT_EMPTY] Cannot drop a schema `$namespace` because it contains objects")) | ||
} else { | ||
assert(e.getMessage().contains("Use CASCADE option to drop a non-empty database")) | ||
} |
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.
interceptContains[AnalysisException] {
sql(s"DROP NAMESPACE $catalogName.$namespace")
}(if (SPARK_RUNTIME_VERSION >= "3.4") {
s"[SCHEMA_NOT_EMPTY] Cannot drop a schema `$namespace` because it contains objects"
} else {
"Use CASCADE option to drop a non-empty database"
})
There's a new-added helper method interceptContains
available in AssertionUtils
on the master branch that helps simplify asserting exception messages.
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.
Oh, thanks~
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.
😀
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.
LGTM. I think it's ready to merge.
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.
Thanks bowen, waitting CI
Thanks, merged to master(1.8.0). |
Why are the changes needed?
This PR aims to unify the exception handling of v1 and v2 during dropDatabase
How was this patch tested?
Add some test cases that check the changes thoroughly including negative and positive cases if possible
Add screenshots for manual tests if appropriate
Run test locally before make a pull request
Was this patch authored or co-authored using generative AI tooling?
No