Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian-wang committed Jan 29, 2016
1 parent 2244999 commit bf429ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,10 @@ case class GetMapValue(child: Expression, key: Expression)
}
}

if ($found && !$values.isNullAt($index)) {
${ev.value} = ${ctx.getValue(values, dataType, index)};
} else {
if (!$found || $values.isNullAt($index)) {
${ev.isNull} = true;
} else {
${ev.value} = ${ctx.getValue(values, dataType, index)};
}
"""
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1465,9 +1465,9 @@ class SQLQuerySuite extends QueryTest with SQLTestUtils with TestHiveSingleton {
}

test("SPARK-13056: Null in map value causes NPE") {
Seq((1, "abc=somestring,cba")).toDF("key", "value").registerTempTable("mapsrc")
sql("""CREATE TABLE maptest AS SELECT str_to_map(value, ",", "=") as col1 FROM mapsrc""")
checkAnswer(sql("SELECT col1['abc'] FROM maptest"), Row("somestring"))
checkAnswer(sql("SELECT col1['cba'] FROM maptest"), Row(null))
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))
}
}

0 comments on commit bf429ca

Please sign in to comment.