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-35347][SQL][FOLLOWUP] Throw exception with an explicit exception type when cannot find the method instead of sys.error #32519

Closed
wants to merge 1 commit into from

Conversation

viirya
Copy link
Member

@viirya viirya commented May 12, 2021

What changes were proposed in this pull request?

A simple follow-up of #32474 to throw exception instead of sys.error.

Why are the changes needed?

An exception only fails the query, instead of sys.error.

Does this PR introduce any user-facing change?

Yes, if Invoke or StaticInvoke cannot find the method, instead of original sys.error now we only throw an exception.

How was this patch tested?

Existing tests.

@viirya
Copy link
Member Author

viirya commented May 12, 2021

cc @cloud-fan

@github-actions github-actions bot added the SQL label May 12, 2021
@HyukjinKwon
Copy link
Member

HyukjinKwon commented May 12, 2021

sys.error which crashes the driver JVM.

I don't think this is true though .. it's just a short cut of java.lang.RuntimeException.

@@ -151,7 +151,7 @@ trait InvokeLike extends Expression with NonSQLExpression {
final def findMethod(cls: Class[_], functionName: String, argClasses: Seq[Class[_]]): Method = {
val method = MethodUtils.getMatchingAccessibleMethod(cls, functionName, argClasses: _*)
if (method == null) {
sys.error(s"Couldn't find $functionName on $cls")
throw QueryExecutionErrors.methodNotDeclaredError(functionName)
Copy link
Member

Choose a reason for hiding this comment

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

This file has one more sys.error?

sys.error(s"Couldn't find a valid constructor on $cls")

The change looks fine for consistency.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fix together? Or another minor PR as this is a followup only.

Copy link
Member

Choose a reason for hiding this comment

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

hm. I think either is okay, but how about assigning a new jira number for replacing all the sys.error in this file with QueryExecutionErrors.xxx methods?

Copy link
Member Author

Choose a reason for hiding this comment

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

sgtm

@viirya
Copy link
Member Author

viirya commented May 12, 2021

I don't think this is true though .. it's just a short cut of java.lang.RuntimeException.

Oh, yea, you're right. cc @cloud-fan

package object sys {
  /** Throw a new RuntimeException with the supplied message.
   *
   *  @return   Nothing.
   */
  def error(message: String): Nothing = throw new RuntimeException(message)
...

@cloud-fan
Copy link
Contributor

ah, somehow I misremember this. Anyway it's better to throw exception manually with an explicit exception type.

@SparkQA
Copy link

SparkQA commented May 12, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/42954/

@SparkQA
Copy link

SparkQA commented May 12, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/42954/

@SparkQA
Copy link

SparkQA commented May 12, 2021

Test build #138433 has finished for PR 32519 at commit 1bcc512.

  • This patch passes all 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.

+1

@dongjoon-hyun
Copy link
Member

BTW, please revise the PR title, @viirya . RuntimeException is also a exception.

@viirya viirya changed the title [SPARK-35347][SQL][FOLLOWUP] Throw exception when cannot find the method [SPARK-35347][SQL][FOLLOWUP] Throw exception with an explicit exception type when cannot find the method instead of sys.error May 12, 2021
@viirya
Copy link
Member Author

viirya commented May 12, 2021

Thanks all! I'm going to merge this first.

As this is a followup only, I also find other sys.error usage, so I'm going to work on other PR to modify them altogether.

@viirya viirya closed this in f156a95 May 12, 2021
@viirya viirya deleted the SPARK-35347-followup branch May 12, 2021 16:56
dongjoon-hyun pushed a commit that referenced this pull request May 13, 2021
### What changes were proposed in this pull request?

This patch replaces `sys.err` usages with explicit exception types.

### Why are the changes needed?

Motivated by the previous comment #32519 (comment), it sounds better to replace `sys.err` usages with explicit exception type.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Existing tests.

Closes #32535 from viirya/replace-sys-err.

Authored-by: Liang-Chi Hsieh <viirya@gmail.com>
Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants