Github user tejasapatil commented on a diff in the pull request:
https://github.com/apache/spark/pull/10964#discussion_r51380304
--- Diff: sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
---
@@ -2056,4 +2056,11 @@ class SQLQuerySuite extends QueryTest with
SharedSQLContext {
)
}
}
+
+ test("SPARK-13056: Null in map value causes NPE") {
+ val df = Seq(1 -> Map("abc" -> "somestring", "cba" ->
null)).toDF("key", "value")
+ df.registerTempTable("maptest")
+ checkAnswer(sql("SELECT value['abc'] FROM maptest"), Row("somestring"))
+ checkAnswer(sql("SELECT value['cba'] FROM maptest"), Row(null))
--- End diff --
You need to modify the test case:
```
scala> sqlContext.sql("SELECT value['cba'] FROM maptest WHERE key =
1").collect()
16/01/31 21:22:13 ERROR Executor: Exception in task 15.0 in stage 2.0 (TID
47)
java.lang.NullPointerException
at
org.apache.spark.sql.catalyst.expressions.UnsafeRowWriters$UTF8StringWriter.getSize(UnsafeRowWriters.java:90)
at
org.apache.spark.sql.catalyst.expressions.GeneratedClass$SpecificUnsafeProjection.apply(Unknown
Source)
at
org.apache.spark.sql.execution.TungstenProject$$anonfun$3$$anonfun$apply$3.apply(basicOperators.scala:90)
at
org.apache.spark.sql.execution.TungstenProject$$anonfun$3$$anonfun$apply$3.apply(basicOperators.scala:88)
at scala.collection.Iterator$$anon$11.next(Iterator.scala:328)
at scala.collection.Iterator$$anon$11.next(Iterator.scala:328)
at scala.collection.Iterator$class.foreach(Iterator.scala:727)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1157)
at
scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)
at
scala.collection.mutable.ArrayBuffer.$plus$plus$eq(ArrayBuffer.scala:103)....
....
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]