Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10964#discussion_r51391066
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala 
---
    @@ -2046,6 +2046,15 @@ 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")
    +    withTempTable("maptest") {
    +      df.registerTempTable("maptest")
    +      checkAnswer(sql("SELECT value['abc'] FROM maptest where key = 1"), 
Row("somestring"))
    --- End diff --
    
    As I explained before, the problem is local optimization: 
https://github.com/apache/spark/pull/10964#discussion_r51380297 , so adding a 
filter here do fixes the problem, by breaking the [local 
optimization](https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala#L1017-L1029),
 and we should add comments to say it.


---
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]

Reply via email to