Skip to content

[SPARK-4274] [SQL] Fix NPE in printing the details of the query plan #3139

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

Closed
wants to merge 1 commit into from

Conversation

chenghao-intel
Copy link
Contributor

No description provided.

@SparkQA
Copy link

SparkQA commented Nov 6, 2014

Test build #23006 has started for PR 3139 at commit d1bcee1.

  • This patch merges cleanly.

@SparkQA
Copy link

SparkQA commented Nov 6, 2014

Test build #23006 has finished for PR 3139 at commit d1bcee1.

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

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/23006/
Test PASSed.

@chenghao-intel
Copy link
Contributor Author

@marmbrus @rxin @liancheng Any comments about this?

@@ -341,12 +341,21 @@ abstract class HiveComparisonTest
val query = new TestHive.HiveQLQueryExecution(queryString)
try { (query, prepareAnswer(query, query.stringResult())) } catch {
case e: Throwable =>
val logicalQueryInString = try {
query.toString
Copy link
Contributor

Choose a reason for hiding this comment

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

In what case does the toString throw an exception? I think thats the real bug. Is it because Code Generation: ${executedPlan.codegenEnabled} is not wrapped in stringOrError?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See

protected abstract class QueryExecution {
...
    override def toString: String =
      s"""== Parsed Logical Plan ==
         |${stringOrError(logical)}
         |== Analyzed Logical Plan ==
         |${stringOrError(analyzed)}
         |== Optimized Logical Plan ==
         |${stringOrError(optimizedPlan)}
         |== Physical Plan ==
         |${stringOrError(executedPlan)}
         |Code Generation: ${executedPlan.codegenEnabled}
         |== RDD ==
      """.stripMargin.trim
  }

logical, analyzed etc. will be computed(which probably cause exception) before passing into stringOrError, not happen inside of stringOrError.

Or you think we'd better to fix the toString here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think thats correct, stringOrError takes a closure so the actual calculation is done inside of the function and should be correctly caught:

scala> def stringOrError[A](f: => A): String =
     |       try f.toString catch { case e: Throwable => e.toString }
stringOrError: [A](f: => A)String

scala> stringOrError(sys.error("test"))
res0: String = java.lang.RuntimeException: test

scala> def error = sys.error("test")
error: Nothing

scala> stringOrError(error)
res1: String = java.lang.RuntimeException: test

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, I didn't know this. Thank you @marmbrus very much for the code snippet.

After debugging, I think you are right, the exception is thrown by ${executedPlan.codegenEnabled}, the executedPlan is null if something wrong in parsing or analyzing etc. I've updated the code again.

@SparkQA
Copy link

SparkQA commented Nov 9, 2014

Test build #23118 has started for PR 3139 at commit f5d7146.

  • This patch merges cleanly.

@SparkQA
Copy link

SparkQA commented Nov 9, 2014

Test build #23118 has finished for PR 3139 at commit f5d7146.

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

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/23118/
Test PASSed.

@chenghao-intel chenghao-intel changed the title [SPARK-4274] [SQL] Print informative message while logical plan analyzing failed in test [SPARK-4274] [SQL] Fix NPE in printing the details of the query plan Nov 11, 2014
@chenghao-intel
Copy link
Contributor Author

I've updated the title of this PR, this is quite simple and ready to be merged.

@marmbrus
Copy link
Contributor

Thanks, merged to master and 1.2.

@asfgit asfgit closed this in c764d0a Nov 11, 2014
asfgit pushed a commit that referenced this pull request Nov 11, 2014
Author: Cheng Hao <[email protected]>

Closes #3139 from chenghao-intel/comparison_test and squashes the following commits:

f5d7146 [Cheng Hao] avoid exception in printing the codegen enabled

(cherry picked from commit c764d0a)
Signed-off-by: Michael Armbrust <[email protected]>
@chenghao-intel chenghao-intel deleted the comparison_test branch July 2, 2015 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants