aboutsummaryrefslogtreecommitdiff
path: root/sql/catalyst/src/test
diff options
context:
space:
mode:
authorDongjoon Hyun <dongjoon@apache.org>2016-07-03 16:59:40 +0800
committerWenchen Fan <wenchen@databricks.com>2016-07-03 16:59:40 +0800
commit54b27c1797fcd32b3f3e9d44e1a149ae396a61e6 (patch)
tree9d00060aa80e539659bbb8d202bfcddf628c885c /sql/catalyst/src/test
parentea990f96930066c36055734d4f17eaf8e496eb3f (diff)
downloadspark-54b27c1797fcd32b3f3e9d44e1a149ae396a61e6.tar.gz
spark-54b27c1797fcd32b3f3e9d44e1a149ae396a61e6.tar.bz2
spark-54b27c1797fcd32b3f3e9d44e1a149ae396a61e6.zip
[SPARK-16278][SPARK-16279][SQL] Implement map_keys/map_values SQL functions
## What changes were proposed in this pull request? This PR adds `map_keys` and `map_values` SQL functions in order to remove Hive fallback. ## How was this patch tested? Pass the Jenkins tests including new testcases. Author: Dongjoon Hyun <dongjoon@apache.org> Closes #13967 from dongjoon-hyun/SPARK-16278.
Diffstat (limited to 'sql/catalyst/src/test')
-rw-r--r--sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CollectionFunctionsSuite.scala13
1 files changed, 13 insertions, 0 deletions
diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CollectionFunctionsSuite.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CollectionFunctionsSuite.scala
index 1aae4678d6..a5f784fdcc 100644
--- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CollectionFunctionsSuite.scala
+++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CollectionFunctionsSuite.scala
@@ -44,6 +44,19 @@ class CollectionFunctionsSuite extends SparkFunSuite with ExpressionEvalHelper {
checkEvaluation(Literal.create(null, ArrayType(StringType)), null)
}
+ test("MapKeys/MapValues") {
+ val m0 = Literal.create(Map("a" -> "1", "b" -> "2"), MapType(StringType, StringType))
+ val m1 = Literal.create(Map[String, String](), MapType(StringType, StringType))
+ val m2 = Literal.create(null, MapType(StringType, StringType))
+
+ checkEvaluation(MapKeys(m0), Seq("a", "b"))
+ checkEvaluation(MapValues(m0), Seq("1", "2"))
+ checkEvaluation(MapKeys(m1), Seq())
+ checkEvaluation(MapValues(m1), Seq())
+ checkEvaluation(MapKeys(m2), null)
+ checkEvaluation(MapValues(m2), null)
+ }
+
test("Sort Array") {
val a0 = Literal.create(Seq(2, 1, 3), ArrayType(IntegerType))
val a1 = Literal.create(Seq[Integer](), ArrayType(IntegerType))