-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-20164][SQL] AnalysisException not tolerant of null query plan. #17486
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
Conversation
|
|
||
| override def getMessage: String = { | ||
| val planAnnotation = plan.map(p => s";\n$p").getOrElse("") | ||
| val planAnnotation = if (plan == null) "" else plan.map(p => s";\n$p").getOrElse("") |
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.
Nit:
val planAnnotation = Option(plan).map(p => s";\n$p").getOrElse("")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.
Changed.
|
We should pass |
|
@gatorsmile Looks like its happening because |
|
Test build #75403 has finished for PR 17486 at commit
|
|
Test build #75407 has finished for PR 17486 at commit
|
|
Test build #75404 has finished for PR 17486 at commit
|
|
|
||
| override def getMessage: String = { | ||
| val planAnnotation = plan.map(p => s";\n$p").getOrElse("") | ||
| val planAnnotation = Option(plan).map(p => s";\n$p").getOrElse("") |
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.
Sorry, my fault. We need another flatten.
val planAnnotation = Option(plan).flatten.map(p => s";\n$p").getOrElse("")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.
Right, updated.
|
Test build #75415 has finished for PR 17486 at commit
|
|
LGTM It sounds like the support of the default value in Scala is weird. I did some searches. Scala omits the default value. Another alternative is to define auxiliary constructor function to explicitly set the default value. |
|
LGTM A variable marked with Quoted from Chapter 25 of Programming in Scala, First Edition: http://www.artima.com/pins1ed/annotations.html
|
|
@kunalkhamar Could you summarize the issue and post it in https://github.com/databricks/scala-style-guide? Thanks! |
The query plan in an `AnalysisException` may be `null` when an `AnalysisException` object is serialized and then deserialized, since `plan` is marked `transient`. Or when someone throws an `AnalysisException` with a null query plan (which should not happen). `def getMessage` is not tolerant of this and throws a `NullPointerException`, leading to loss of information about the original exception. The fix is to add a `null` check in `getMessage`. - Unit test Author: Kunal Khamar <kkhamar@outlook.com> Closes #17486 from kunalkhamar/spark-20164. (cherry picked from commit 254877c) Signed-off-by: Xiao Li <gatorsmile@gmail.com>
|
Thanks! Merging to master and 2.1. |
|
@gatorsmile Verified the behaviour using this, it makes Not sure what to add and where in the scala-style-guide? |
What changes were proposed in this pull request?
The query plan in an
AnalysisExceptionmay benullwhen anAnalysisExceptionobject is serialized and then deserialized, sinceplanis marked@transient. Or when someone throws anAnalysisExceptionwith a null query plan (which should not happen).def getMessageis not tolerant of this and throws aNullPointerException, leading to loss of information about the original exception.The fix is to add a
nullcheck ingetMessage.How was this patch tested?