Github user kiszk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21073#discussion_r189423538
  
    --- Diff: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CollectionExpressionsSuite.scala
 ---
    @@ -56,6 +58,93 @@ class CollectionExpressionsSuite extends SparkFunSuite 
with ExpressionEvalHelper
         checkEvaluation(MapValues(m2), null)
       }
     
    +  test("Map Concat") {
    +    val m0 = Literal.create(Map("a" -> "1", "b" -> "2"), 
MapType(StringType, StringType,
    +      valueContainsNull = false))
    +    val m1 = Literal.create(Map("c" -> "3", "a" -> "4"), 
MapType(StringType, StringType,
    +      valueContainsNull = false))
    +    val m2 = Literal.create(Map("d" -> "4", "e" -> "5"), 
MapType(StringType, StringType))
    +    val m3 = Literal.create(Map("a" -> "1", "b" -> "2"), 
MapType(StringType, StringType))
    +    val m4 = Literal.create(Map("a" -> null, "c" -> "3"), 
MapType(StringType, StringType))
    +    val m5 = Literal.create(Map("a" -> 1, "b" -> 2), MapType(StringType, 
IntegerType))
    +    val m6 = Literal.create(Map("a" -> null, "c" -> 3), 
MapType(StringType, IntegerType))
    +    val m7 = Literal.create(Map(List(1, 2) -> 1, List(3, 4) -> 2),
    +      MapType(ArrayType(IntegerType), IntegerType))
    +    val m8 = Literal.create(Map(List(5, 6) -> 3, List(1, 2) -> 4),
    +      MapType(ArrayType(IntegerType), IntegerType))
    +    val m9 = Literal.create(Map(Map(1 -> 2, 3 -> 4) -> 1, Map(5 -> 6, 7 -> 
8) -> 2),
    +      MapType(MapType(IntegerType, IntegerType), IntegerType))
    +    val m10 = Literal.create(Map(Map(9 -> 10, 11 -> 12) -> 3, Map(1 -> 2, 
3 -> 4) -> 4),
    +      MapType(MapType(IntegerType, IntegerType), IntegerType))
    +    val mNull = Literal.create(null, MapType(StringType, StringType))
    +
    +    // overlapping maps
    +    checkEvaluation(MapConcat(Seq(m0, m1)),
    +      mutable.LinkedHashMap("a" -> "4", "b" -> "2", "c" -> "3"))
    +
    +    // maps with no overlap
    +    checkEvaluation(MapConcat(Seq(m0, m2)),
    +      mutable.LinkedHashMap("a" -> "1", "b" -> "2", "d" -> "4", "e" -> 
"5"))
    +
    +    // 3 maps
    +    checkEvaluation(MapConcat(Seq(m0, m1, m2)),
    +      mutable.LinkedHashMap("a" -> "4", "b" -> "2", "c" -> "3", "d" -> 
"4", "e" -> "5"))
    +
    +    // null reference values
    +    checkEvaluation(MapConcat(Seq(m3, m4)),
    +      mutable.LinkedHashMap("a" -> null, "b" -> "2", "c" -> "3"))
    +
    +    // null primitive values
    +    checkEvaluation(MapConcat(Seq(m5, m6)),
    +      mutable.LinkedHashMap("a" -> null, "b" -> 2, "c" -> 3))
    +
    +    // keys that are arrays, with overlap
    +    checkEvaluation(MapConcat(Seq(m7, m8)),
    +      mutable.LinkedHashMap(List(1, 2) -> 4, List(3, 4) -> 2, List(5, 6) 
-> 3))
    +
    +    // null map
    +    checkEvaluation(MapConcat(Seq(m0, mNull)),
    +      null)
    +    checkEvaluation(MapConcat(Seq(mNull, m0)),
    +      null)
    +    checkEvaluation(MapConcat(Seq(mNull, mNull)),
    +      null)
    +    checkEvaluation(MapConcat(Seq(mNull)),
    +      null)
    +
    +    // single map
    +    checkEvaluation(MapConcat(Seq(m0)),
    +      mutable.LinkedHashMap("a" -> "1", "b" -> "2"))
    +
    +    // no map
    +    checkEvaluation(MapConcat(Seq()),
    --- End diff --
    
    nit: `Seq.empty`


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to