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

[SPARK-29675][SQL] Add exception when isolationLevel is Illegal #26334

Closed
wants to merge 3 commits into from

Conversation

ulysses-you
Copy link
Contributor

What changes were proposed in this pull request?

Now we use JDBC api and set an Illegal isolationLevel option, spark will throw a scala.MatchError, it's not friendly to user. So we should add an IllegalArgumentException.

Why are the changes needed?

Make exception friendly to user.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Add UT.

@maropu
Copy link
Member

maropu commented Oct 31, 2019

ok to test

@@ -177,6 +177,10 @@ class JDBCOptions(
case "READ_COMMITTED" => Connection.TRANSACTION_READ_COMMITTED
case "REPEATABLE_READ" => Connection.TRANSACTION_REPEATABLE_READ
case "SERIALIZABLE" => Connection.TRANSACTION_SERIALIZABLE
case other => throw new IllegalArgumentException(
s"Invalid value `$other` for parameter `$JDBC_TXN_ISOLATION_LEVEL`. This can be " +
s"`NONE`, `READ_UNCOMMITTED`, `READ_COMMITTED`, `REPEATABLE_READ` or `SERIALIZABLE`."
Copy link
Member

Choose a reason for hiding this comment

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

nit: plz drop s in the head.

Copy link
Member

@maropu maropu left a comment

Choose a reason for hiding this comment

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

Copy link
Member

@HyukjinKwon HyukjinKwon left a comment

Choose a reason for hiding this comment

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

Thanks for cc'ing me @maropu. LGTM too

@maropu
Copy link
Member

maropu commented Oct 31, 2019

Thanks, @HyukjinKwon ! Pending Jenkins.

@@ -1649,4 +1649,17 @@ class JDBCSuite extends QueryTest
}
}
}

test("SPARK-29675 Add exception when isolationLevel is Illegal") {
Copy link
Member

Choose a reason for hiding this comment

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

Super nit. @ulysses-you . We don't use JIRA ID for the improvement test cases. It's used for bug fixes only.

Copy link
Member

Choose a reason for hiding this comment

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

I discussed with @dongjoon-hyun offline. I will send an email to dev mailing list to discuss and officially document this test prefix for JIRA ID, after having some more offline discussions with some other PMCs.

Copy link
Member

Choose a reason for hiding this comment

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

Looks nice, thx, PMC guys!

@SparkQA
Copy link

SparkQA commented Oct 31, 2019

Test build #112978 has finished for PR 26334 at commit baf1f45.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@maropu
Copy link
Member

maropu commented Oct 31, 2019

@ulysses-you Can you remove the prefix before merging? #26334 (comment)

@ulysses-you
Copy link
Contributor Author

Thanks for your review @maropu @HyukjinKwon @dongjoon-hyun . I have Fixed it.

@maropu
Copy link
Member

maropu commented Oct 31, 2019

Thanks, @ulysses-you ! Pending, Jenkins.

@SparkQA
Copy link

SparkQA commented Oct 31, 2019

Test build #112995 has finished for PR 26334 at commit 0de8529.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@ulysses-you
Copy link
Contributor Author

retest this please

@maropu
Copy link
Member

maropu commented Oct 31, 2019

Jenkins, retest this please

@SparkQA
Copy link

SparkQA commented Oct 31, 2019

Test build #113020 has finished for PR 26334 at commit 0de8529.

  • This patch fails SparkR unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

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

This passed all tests including SparkR.
The only failure is CRAN incoming feasibility check which is not our issue.

* checking CRAN incoming feasibility ...Error in .check_package_CRAN_incoming(pkgdir) : 
  dims [product 24] do not match the length of object [0]

I'll merge this. Thank you, @ulysses-you , @maropu , @HyukjinKwon !

@@ -177,6 +177,10 @@ class JDBCOptions(
case "READ_COMMITTED" => Connection.TRANSACTION_READ_COMMITTED
case "REPEATABLE_READ" => Connection.TRANSACTION_REPEATABLE_READ
case "SERIALIZABLE" => Connection.TRANSACTION_SERIALIZABLE
case other => throw new IllegalArgumentException(
s"Invalid value `$other` for parameter `$JDBC_TXN_ISOLATION_LEVEL`. This can be " +
Copy link
Member

Choose a reason for hiding this comment

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

Nit: back-ticks aren't meaningful here right?

.load()
}.getMessage
assert(e.contains(
"Invalid value `test` for parameter `isolationLevel`. This can be " +
Copy link
Member

Choose a reason for hiding this comment

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

You can probably just check for the first sentence rather than depend on this exact entire string. But it doesn't matter much.

@srowen
Copy link
Member

srowen commented Oct 31, 2019

Oh ha sorry you merged it. The back ticks are superfluous but it doesn't matter, just leave it.

@dongjoon-hyun
Copy link
Member

Oops. Sorry, @srowen . :)

@maropu
Copy link
Member

maropu commented Oct 31, 2019

Thanks for merging, @dongjoon-hyun !

@ulysses-you
Copy link
Contributor Author

Thanks all !

@ulysses-you ulysses-you deleted the SPARK-29675 branch June 24, 2021 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
6 participants