Skip to content
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

Closed
wants to merge 1 commit into from
Closed

[KSHC] Unify the exception handling of v1 and v2 during dropDatabase #5225

wants to merge 1 commit into from

Conversation

yikf
Copy link
Contributor

@yikf yikf commented Aug 31, 2023

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

@codecov-commenter
Copy link

codecov-commenter commented Aug 31, 2023

Codecov Report

Merging #5225 (628497f) into master (c844f18) will not change coverage.
The diff coverage is n/a.

❗ Current head 628497f differs from pull request most recent head 3be33af. Consider uploading reports for the commit 3be33af to get more accurate results

@@          Coverage Diff           @@
##           master   #5225   +/-   ##
======================================
  Coverage    0.00%   0.00%           
======================================
  Files         589     589           
  Lines       33311   33307    -4     
  Branches     4399    4397    -2     
======================================
+ Misses      33311   33307    -4     
Files Changed Coverage Δ
...kyuubi/spark/connector/hive/HiveTableCatalog.scala 0.00% <ø> (ø)

... and 3 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@bowenliang123 bowenliang123 left a 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.

Comment on lines 73 to 82
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"))
}
Copy link
Contributor

@bowenliang123 bowenliang123 Aug 31, 2023

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, thanks~

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😀

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks bowen, waitting CI

@bowenliang123 bowenliang123 added this to the v1.8.0 milestone Sep 1, 2023
@bowenliang123
Copy link
Contributor

Thanks, merged to master(1.8.0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants