Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add a null map testcase and remove redundant implementation.
  • Loading branch information
dongjoon-hyun committed Jul 2, 2016
commit c0dac4bacbd07d244ea716db076b7a638be31837
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ case class MapKeys(child: Expression)

override def dataType: DataType = ArrayType(child.dataType.asInstanceOf[MapType].keyType)

override def foldable: Boolean = child.foldable

override def nullSafeEval(map: Any): Any = {
map.asInstanceOf[MapData].keyArray()
}
Expand All @@ -82,8 +80,6 @@ case class MapValues(child: Expression)

override def dataType: DataType = ArrayType(child.dataType.asInstanceOf[MapType].valueType)

override def foldable: Boolean = child.foldable

override def nullSafeEval(map: Any): Any = {
map.asInstanceOf[MapData].valueArray()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ class CollectionFunctionsSuite extends SparkFunSuite with ExpressionEvalHelper {
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") {
Expand Down