Github user ueshin commented on a diff in the pull request:
https://github.com/apache/spark/pull/21986#discussion_r207702742
--- Diff:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/HigherOrderFunctionsSuite.scala
---
@@ -94,4 +94,53 @@ class HigherOrderFunctionsSuite extends SparkFunSuite
with ExpressionEvalHelper
checkEvaluation(transform(aai, array => Cast(transform(array,
plusIndex), StringType)),
Seq("[1, 3, 5]", null, "[4, 6]"))
}
+
+ test("MapFilter") {
+ def mapFilter(expr: Expression, f: (Expression, Expression) =>
Expression): Expression = {
+ val mt = expr.dataType.asInstanceOf[MapType]
+ MapFilter(expr, createLambda(mt.keyType, false, mt.valueType,
mt.valueContainsNull, f))
+ }
+ val mii0 = Literal.create(Map(1 -> 0, 2 -> 10, 3 -> -1),
+ MapType(IntegerType, IntegerType, valueContainsNull = false))
+ val mii1 = Literal.create(Map(1 -> null, 2 -> 10, 3 -> null),
+ MapType(IntegerType, IntegerType, valueContainsNull = true))
+ val miin = Literal.create(null, MapType(IntegerType, IntegerType,
valueContainsNull = false))
+
+ val kGreaterThanV: (Expression, Expression) => Expression = (k, v) =>
k > v
+
+ checkEvaluation(mapFilter(mii0, kGreaterThanV), Map(1 -> 0, 3 -> -1))
+ checkEvaluation(mapFilter(mii1, kGreaterThanV), Map())
+ checkEvaluation(mapFilter(miin, kGreaterThanV), null)
+
+ val valueNull: (Expression, Expression) => Expression = (_, v) =>
v.isNull
--- End diff --
nit: `valueIsNull`?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]