aboutsummaryrefslogtreecommitdiff
path: root/sql/core
diff options
context:
space:
mode:
authorKunal Khamar <kkhamar@outlook.com>2017-03-31 09:17:22 -0700
committerXiao Li <gatorsmile@gmail.com>2017-03-31 09:17:22 -0700
commit254877c2f04414c70d92fa0a00c0ecee1d73aba7 (patch)
tree1f686f1872559eb077ad4bd40c245a586e6789e6 /sql/core
parenta8a765b3f302c078cb9519c4a17912cd38b9680c (diff)
downloadspark-254877c2f04414c70d92fa0a00c0ecee1d73aba7.tar.gz
spark-254877c2f04414c70d92fa0a00c0ecee1d73aba7.tar.bz2
spark-254877c2f04414c70d92fa0a00c0ecee1d73aba7.zip
[SPARK-20164][SQL] AnalysisException not tolerant of null query plan.
## What changes were proposed in this pull request? 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`. ## How was this patch tested? - Unit test Author: Kunal Khamar <kkhamar@outlook.com> Closes #17486 from kunalkhamar/spark-20164.
Diffstat (limited to 'sql/core')
-rw-r--r--sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala8
1 files changed, 8 insertions, 0 deletions
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
index d9e0196c57..0dd9296a3f 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
@@ -2598,4 +2598,12 @@ class SQLQuerySuite extends QueryTest with SharedSQLContext {
}
assert(!jobStarted.get(), "Command should not trigger a Spark job.")
}
+
+ test("SPARK-20164: AnalysisException should be tolerant to null query plan") {
+ try {
+ throw new AnalysisException("", None, None, plan = null)
+ } catch {
+ case ae: AnalysisException => assert(ae.plan == null && ae.getMessage == ae.getSimpleMessage)
+ }
+ }
}