You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by maropu <gi...@git.apache.org> on 2018/08/06 01:39:24 UTC

[GitHub] spark pull request #21102: [SPARK-23913][SQL] Add array_intersect function

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

    https://github.com/apache/spark/pull/21102#discussion_r207758427
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/DataFrameFunctionsSuite.scala ---
    @@ -1647,6 +1647,60 @@ class DataFrameFunctionsSuite extends QueryTest with SharedSQLContext {
         assert(result10.first.schema(0).dataType === expectedType10)
       }
     
    +  test("array_intersect functions") {
    +    val df1 = Seq((Array(1, 2, 4), Array(4, 2))).toDF("a", "b")
    +    val ans1 = Row(Seq(2, 4))
    +    checkAnswer(df1.select(array_intersect($"a", $"b")), ans1)
    +    checkAnswer(df1.selectExpr("array_intersect(a, b)"), ans1)
    +
    +    val df2 = Seq((Array[Integer](1, 2, null, 4, 5), Array[Integer](-5, 4, null, 2, -1)))
    +      .toDF("a", "b")
    +    val ans2 = Row(Seq(2, null, 4))
    +    checkAnswer(df2.select(array_intersect($"a", $"b")), ans2)
    +    checkAnswer(df2.selectExpr("array_intersect(a, b)"), ans2)
    +
    +    val df3 = Seq((Array(1L, 2L, 4L), Array(4L, 2L))).toDF("a", "b")
    +    val ans3 = Row(Seq(2L, 4L))
    +    checkAnswer(df3.select(array_intersect($"a", $"b")), ans3)
    +    checkAnswer(df3.selectExpr("array_intersect(a, b)"), ans3)
    +
    +    val df4 = Seq(
    +      (Array[java.lang.Long](1L, 2L, null, 4L, 5L), Array[java.lang.Long](-5L, 4L, null, 2L, -1L)))
    +      .toDF("a", "b")
    +    val ans4 = Row(Seq(2L, null, 4L))
    +    checkAnswer(df4.select(array_intersect($"a", $"b")), ans4)
    +    checkAnswer(df4.selectExpr("array_intersect(a, b)"), ans4)
    +
    +    val df5 = Seq((Array("c", null, "a", "f"), Array("b", "a", null, "g"))).toDF("a", "b")
    +    val ans5 = Row(Seq(null, "a"))
    +    checkAnswer(df5.select(array_intersect($"a", $"b")), ans5)
    +    checkAnswer(df5.selectExpr("array_intersect(a, b)"), ans5)
    +
    +    val df6 = Seq((null, null)).toDF("a", "b")
    +    intercept[AnalysisException] {
    --- End diff --
    
    Could you also check the error message?


---

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