Skip to content

Commit

Permalink
use withTempTable
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian-wang committed Feb 1, 2016
1 parent 21f29a5 commit 898cf20
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"), Row("somestring"))
checkAnswer(sql("SELECT value['cba'] FROM maptest"), Row(null))
}
}

test("hash function") {
val df = Seq(1 -> "a", 2 -> "b").toDF("i", "j")
withTempTable("tbl") {
Expand All @@ -2056,11 +2065,4 @@ 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))
}
}

0 comments on commit 898cf20

Please sign in to comment.