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

[GitHub] spark pull request #22031: [TODO][SPARK-23932][SQL] Higher order function zi...

GitHub user techaddict opened a pull request:

    https://github.com/apache/spark/pull/22031

    [TODO][SPARK-23932][SQL] Higher order function zip_with

    ## What changes were proposed in this pull request?
    Merges the two given arrays, element-wise, into a single array using function. If one array is shorter, nulls are appended at the end to match the length of the longer array, before applying function:
    ```
        SELECT zip_with(ARRAY[1, 3, 5], ARRAY['a', 'b', 'c'], (x, y) -> (y, x)); -- [ROW('a', 1), ROW('b', 3), ROW('c', 5)]
        SELECT zip_with(ARRAY[1, 2], ARRAY[3, 4], (x, y) -> x + y); -- [4, 6]
        SELECT zip_with(ARRAY['a', 'b', 'c'], ARRAY['d', 'e', 'f'], (x, y) -> concat(x, y)); -- ['ad', 'be', 'cf']
        SELECT zip_with(ARRAY['a'], ARRAY['d', null, 'f'], (x, y) -> coalesce(x, y)); -- ['a', null, 'f']
    ```
    ## How was this patch tested?
    Added tests

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/techaddict/spark SPARK-23932

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/22031.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #22031
    
----
commit 03d19cee425be90a61b60163ff9d6740716d45a6
Author: Sandeep Singh <sa...@...>
Date:   2018-08-03T04:15:00Z

    .

commit 6f91777de93121d668ff11e7701f449bb4c96337
Author: Sandeep Singh <sa...@...>
Date:   2018-08-04T22:00:38Z

    fix description

----


---

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


[GitHub] spark pull request #22031: [TODO][SPARK-23932][SQL] Higher order function zi...

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22031#discussion_r208444629
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/DataFrameFunctionsSuite.scala ---
    @@ -2117,6 +2117,65 @@ class DataFrameFunctionsSuite extends QueryTest with SharedSQLContext {
         assert(ex4.getMessage.contains("data type mismatch: argument 3 requires int type"))
       }
     
    +  test("zip_with function - arrays for primitive type not containing null") {
    +    val df1 = Seq(
    +      (Seq(9001, 9002, 9003), Seq(4, 5, 6)),
    +      (Seq(1, 2), Seq(3, 4)),
    +      (Seq.empty[Int], Seq.empty[Int]),
    +      (null, null)
    +    ).toDF("val1", "val2")
    +    val df2 = Seq(
    +      (Seq(1, 2, 3), Seq("a", "b", "c")),
    +      (Seq(1, 2, 3), Seq("a", "b"))
    +    ).toDF("val1", "val2")
    +
    +    def testArrayOfPrimitiveTypeNotContainsNull(): Unit = {
    +      val expectedValue1 = Seq(
    +        Row(Seq(9005, 9007, 9009)),
    +        Row(Seq(4, 6)),
    +        Row(Seq.empty),
    +        Row(null))
    +      checkAnswer(df1.selectExpr("zip_with(val1, val2, (x, y) -> x + y)"), expectedValue1)
    +
    +      val expectedValue2 = Seq(
    +        Row(Seq(Row("a", 1), Row("b", 2), Row("c", 3))),
    +        Row(Seq(Row("a", 1), Row("b", 2), Row(null, 3))))
    +      checkAnswer(df2.selectExpr("zip_with(val1, val2, (x, y) -> (y, x))"), expectedValue2)
    +    }
    +
    +    // Test with local relation, the Project will be evaluated without codegen
    +    testArrayOfPrimitiveTypeNotContainsNull()
    +    // Test with cached relation, the Project will be evaluated with codegen
    +    df1.cache()
    +    df2.cache()
    +    testArrayOfPrimitiveTypeNotContainsNull()
    +  }
    +
    +  test("zip_with function - arrays for primitive type containing null") {
    +    val df1 = Seq[(Seq[Integer], Seq[Integer])](
    +      (Seq(9001, null, 9003), Seq(4, 5, 6)),
    +      (Seq(1, null, 2, 4), Seq(3, 4)),
    +      (Seq.empty, Seq.empty),
    +      (null, null)
    +    ).toDF("val1", "val2")
    +
    +    def testArrayOfPrimitiveTypeContainsNull(): Unit = {
    +      val expectedValue1 = Seq(
    +        Row(Seq(9005, null, 9009)),
    +        Row(Seq(4, null, null, null)),
    +        Row(Seq.empty),
    +        Row(null))
    +      checkAnswer(df1.selectExpr("zip_with(val1, val2, (x, y) -> x + y)"), expectedValue1)
    +    }
    +
    +    // Test with local relation, the Project will be evaluated without codegen
    +    testArrayOfPrimitiveTypeContainsNull()
    +    // Test with cached relation, the Project will be evaluated with codegen
    +    df1.cache()
    +    testArrayOfPrimitiveTypeContainsNull()
    +  }
    +
    +
    --- End diff --
    
    Can you add a test for invalid cases?


---

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


[GitHub] spark pull request #22031: [TODO][SPARK-23932][SQL] Higher order function zi...

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22031#discussion_r208445494
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/DataFrameFunctionsSuite.scala ---
    @@ -2117,6 +2117,65 @@ class DataFrameFunctionsSuite extends QueryTest with SharedSQLContext {
         assert(ex4.getMessage.contains("data type mismatch: argument 3 requires int type"))
       }
     
    +  test("zip_with function - arrays for primitive type not containing null") {
    +    val df1 = Seq(
    +      (Seq(9001, 9002, 9003), Seq(4, 5, 6)),
    +      (Seq(1, 2), Seq(3, 4)),
    +      (Seq.empty[Int], Seq.empty[Int]),
    +      (null, null)
    +    ).toDF("val1", "val2")
    +    val df2 = Seq(
    +      (Seq(1, 2, 3), Seq("a", "b", "c")),
    +      (Seq(1, 2, 3), Seq("a", "b"))
    +    ).toDF("val1", "val2")
    +
    +    def testArrayOfPrimitiveTypeNotContainsNull(): Unit = {
    +      val expectedValue1 = Seq(
    +        Row(Seq(9005, 9007, 9009)),
    +        Row(Seq(4, 6)),
    +        Row(Seq.empty),
    +        Row(null))
    +      checkAnswer(df1.selectExpr("zip_with(val1, val2, (x, y) -> x + y)"), expectedValue1)
    +
    +      val expectedValue2 = Seq(
    +        Row(Seq(Row("a", 1), Row("b", 2), Row("c", 3))),
    +        Row(Seq(Row("a", 1), Row("b", 2), Row(null, 3))))
    +      checkAnswer(df2.selectExpr("zip_with(val1, val2, (x, y) -> (y, x))"), expectedValue2)
    +    }
    +
    +    // Test with local relation, the Project will be evaluated without codegen
    +    testArrayOfPrimitiveTypeNotContainsNull()
    +    // Test with cached relation, the Project will be evaluated with codegen
    +    df1.cache()
    +    df2.cache()
    +    testArrayOfPrimitiveTypeNotContainsNull()
    +  }
    +
    +  test("zip_with function - arrays for primitive type containing null") {
    +    val df1 = Seq[(Seq[Integer], Seq[Integer])](
    +      (Seq(9001, null, 9003), Seq(4, 5, 6)),
    +      (Seq(1, null, 2, 4), Seq(3, 4)),
    +      (Seq.empty, Seq.empty),
    +      (null, null)
    +    ).toDF("val1", "val2")
    +
    +    def testArrayOfPrimitiveTypeContainsNull(): Unit = {
    +      val expectedValue1 = Seq(
    +        Row(Seq(9005, null, 9009)),
    +        Row(Seq(4, null, null, null)),
    +        Row(Seq.empty),
    +        Row(null))
    +      checkAnswer(df1.selectExpr("zip_with(val1, val2, (x, y) -> x + y)"), expectedValue1)
    +    }
    +
    +    // Test with local relation, the Project will be evaluated without codegen
    +    testArrayOfPrimitiveTypeContainsNull()
    +    // Test with cached relation, the Project will be evaluated with codegen
    +    df1.cache()
    +    testArrayOfPrimitiveTypeContainsNull()
    +  }
    +
    +
    --- End diff --
    
    Also can you add tests to `HigherOrderFunctionsSuite` to check more explicit patterns?


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    **[Test build #94391 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/94391/testReport)** for PR 22031 at commit [`14ef371`](https://github.com/apache/spark/commit/14ef371bdef36df170ec3e487598514ef4967e0e).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `case class ArraysZipWith(`


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/2237/
    Test PASSed.


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/94845/
    Test PASSed.


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    **[Test build #94830 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/94830/testReport)** for PR 22031 at commit [`92cb34a`](https://github.com/apache/spark/commit/92cb34af9c1e5742d9fa21f677645daea029bfd6).
     * This patch **fails Spark unit tests**.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `case class ZipWith(left: Expression, right: Expression, function: Expression)`


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/2243/
    Test PASSed.


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    **[Test build #94833 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/94833/testReport)** for PR 22031 at commit [`0342ed9`](https://github.com/apache/spark/commit/0342ed934e65c13c43081f464503800118383a44).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark pull request #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/spark/pull/22031


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Build finished. Test PASSed.


---

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


[GitHub] spark pull request #22031: [TODO][SPARK-23932][SQL] Higher order function zi...

Posted by mn-mikke <gi...@git.apache.org>.
Github user mn-mikke commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22031#discussion_r209920407
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala ---
    @@ -442,3 +442,91 @@ case class ArrayAggregate(
     
       override def prettyName: String = "aggregate"
     }
    +
    +// scalastyle:off line.size.limit
    +@ExpressionDescription(
    +  usage = "_FUNC_(left, right, func) - Merges the two given arrays, element-wise, into a single array using function. If one array is shorter, nulls are appended at the end to match the length of the longer array, before applying function.",
    +  examples = """
    +    Examples:
    +      > SELECT _FUNC_(array(1, 2, 3), array('a', 'b', 'c'), (x, y) -> (y, x));
    +       array(('a', 1), ('b', 3), ('c', 5))
    +      > SELECT _FUNC_(array(1, 2), array(3, 4), (x, y) -> x + y));
    +       array(4, 6)
    +      > SELECT _FUNC_(array('a', 'b', 'c'), array('d', 'e', 'f'), (x, y) -> concat(x, y));
    +       array('ad', 'be', 'cf')
    +  """,
    +  since = "2.4.0")
    +// scalastyle:on line.size.limit
    +case class ArraysZipWith(
    +    left: Expression,
    +    right: Expression,
    +    function: Expression)
    +  extends HigherOrderFunction with CodegenFallback with ExpectsInputTypes {
    +
    +  override def inputs: Seq[Expression] = List(left, right)
    +
    +  override def functions: Seq[Expression] = List(function)
    +
    +  def expectingFunctionType: AbstractDataType = AnyDataType
    +  @transient lazy val functionForEval: Expression = functionsForEval.head
    +
    +  override def inputTypes: Seq[AbstractDataType] = Seq(ArrayType, ArrayType, expectingFunctionType)
    +
    +  override def nullable: Boolean = inputs.exists(_.nullable)
    +
    +  override def dataType: ArrayType = ArrayType(function.dataType, function.nullable)
    +
    +  override def bind(f: (Expression, Seq[(DataType, Boolean)]) => LambdaFunction): ArraysZipWith = {
    +    val (leftElementType, leftContainsNull) = left.dataType match {
    --- End diff --
    
    This comment is not valid anymore. The method has been removed by [#22075](https://github.com/apache/spark/pull/22075).


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Thanks! merging to master.


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    LGTM pending Jenkins.


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark pull request #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22031#discussion_r210466854
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala ---
    @@ -687,3 +687,89 @@ case class MapZipWith(left: Expression, right: Expression, function: Expression)
     
       override def prettyName: String = "map_zip_with"
     }
    +
    +// scalastyle:off line.size.limit
    +@ExpressionDescription(
    +  usage = "_FUNC_(left, right, func) - Merges the two given arrays, element-wise, into a single array using function. If one array is shorter, nulls are appended at the end to match the length of the longer array, before applying function.",
    +  examples = """
    +    Examples:
    +      > SELECT _FUNC_(array(1, 2, 3), array('a', 'b', 'c'), (x, y) -> (y, x));
    +       array(('a', 1), ('b', 3), ('c', 5))
    +      > SELECT _FUNC_(array(1, 2), array(3, 4), (x, y) -> x + y));
    +       array(4, 6)
    +      > SELECT _FUNC_(array('a', 'b', 'c'), array('d', 'e', 'f'), (x, y) -> concat(x, y));
    +       array('ad', 'be', 'cf')
    +  """,
    +  since = "2.4.0")
    +// scalastyle:on line.size.limit
    +case class ZipWith(left: Expression, right: Expression, function: Expression)
    +  extends HigherOrderFunction with CodegenFallback {
    +
    +  def functionForEval: Expression = functionsForEval.head
    +
    +  override def arguments: Seq[Expression] = left :: right :: Nil
    +
    +  override def argumentTypes: Seq[AbstractDataType] = ArrayType :: ArrayType :: Nil
    +
    +  override def functions: Seq[Expression] = List(function)
    +
    +  override def functionTypes: Seq[AbstractDataType] = AnyDataType :: Nil
    +
    +  override def nullable: Boolean = left.nullable || right.nullable
    +
    +  override def dataType: ArrayType = ArrayType(function.dataType, function.nullable)
    +
    +  override def bind(f: (Expression, Seq[(DataType, Boolean)]) => LambdaFunction): ZipWith = {
    +    val (leftElementType, leftContainsNull) = left.dataType match {
    +      case ArrayType(elementType, containsNull) => (elementType, containsNull)
    +      case _ =>
    +        val ArrayType(elementType, containsNull) = ArrayType.defaultConcreteType
    +        (elementType, containsNull)
    +    }
    +    val (rightElementType, rightContainsNull) = right.dataType match {
    +      case ArrayType(elementType, containsNull) => (elementType, containsNull)
    +      case _ =>
    +        val ArrayType(elementType, containsNull) = ArrayType.defaultConcreteType
    +        (elementType, containsNull)
    +    }
    --- End diff --
    
    Now we can do:
    
    ```scala
    val ArrayType(leftElementType, leftContainsNull) = left.dataType
    val ArrayType(rightElementType, rightContainsNull) = right.dataType
    ```



---

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


[GitHub] spark pull request #22031: [TODO][SPARK-23932][SQL] Higher order function zi...

Posted by crafty-coder <gi...@git.apache.org>.
Github user crafty-coder commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22031#discussion_r208387111
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala ---
    @@ -442,3 +442,93 @@ case class ArrayAggregate(
     
       override def prettyName: String = "aggregate"
     }
    +
    +/**
    + * Transform elements in an array using the transform function. This is similar to
    + * a `map` in functional programming.
    + */
    +// scalastyle:off line.size.limit
    +@ExpressionDescription(
    +  usage = "_FUNC_(expr, func) - Merges the two given arrays, element-wise, into a single array using function. If one array is shorter, nulls are appended at the end to match the length of the longer array, before applying function.",
    +  examples = """
    +    Examples:
    +      > SELECT _FUNC_(array(1, 2, 3), x -> x + 1);
    --- End diff --
    
    The examples are not accurate.
    
    You could something like:
    
    ```
     > SELECT _FUNC_(array(1, 2, 3), array('a', 'b', 'c'), (x, y) -> (y, x));                           
      array(('a', 1), ('b', 3), ('c', 5))                                                               
     > SELECT _FUNC_(array(1, 2), array(3, 4), (x, y) -> x + y));                                       
      array(4, 6)                                                                                       
     > SELECT _FUNC_(array('a', 'b', 'c'), array('d', 'e', 'f'), (x, y) -> concat(x, y));               
      array('ad', 'be', 'cf')                                                                           
    ```


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    **[Test build #94391 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/94391/testReport)** for PR 22031 at commit [`14ef371`](https://github.com/apache/spark/commit/14ef371bdef36df170ec3e487598514ef4967e0e).


---

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


[GitHub] spark pull request #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22031#discussion_r210467354
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala ---
    @@ -442,3 +442,91 @@ case class ArrayAggregate(
     
       override def prettyName: String = "aggregate"
     }
    +
    +// scalastyle:off line.size.limit
    +@ExpressionDescription(
    +  usage = "_FUNC_(left, right, func) - Merges the two given arrays, element-wise, into a single array using function. If one array is shorter, nulls are appended at the end to match the length of the longer array, before applying function.",
    +  examples = """
    +    Examples:
    +      > SELECT _FUNC_(array(1, 2, 3), array('a', 'b', 'c'), (x, y) -> (y, x));
    +       array(('a', 1), ('b', 3), ('c', 5))
    +      > SELECT _FUNC_(array(1, 2), array(3, 4), (x, y) -> x + y));
    +       array(4, 6)
    +      > SELECT _FUNC_(array('a', 'b', 'c'), array('d', 'e', 'f'), (x, y) -> concat(x, y));
    +       array('ad', 'be', 'cf')
    +  """,
    +  since = "2.4.0")
    +// scalastyle:on line.size.limit
    +case class ArraysZipWith(
    +    left: Expression,
    +    right: Expression,
    +    function: Expression)
    +  extends HigherOrderFunction with CodegenFallback with ExpectsInputTypes {
    +
    +  override def inputs: Seq[Expression] = List(left, right)
    +
    +  override def functions: Seq[Expression] = List(function)
    +
    +  def expectingFunctionType: AbstractDataType = AnyDataType
    +  @transient lazy val functionForEval: Expression = functionsForEval.head
    +
    +  override def inputTypes: Seq[AbstractDataType] = Seq(ArrayType, ArrayType, expectingFunctionType)
    +
    +  override def nullable: Boolean = inputs.exists(_.nullable)
    +
    +  override def dataType: ArrayType = ArrayType(function.dataType, function.nullable)
    +
    +  override def bind(f: (Expression, Seq[(DataType, Boolean)]) => LambdaFunction): ArraysZipWith = {
    +    val (leftElementType, leftContainsNull) = left.dataType match {
    +      case ArrayType(elementType, containsNull) => (elementType, containsNull)
    +      case _ =>
    +        val ArrayType(elementType, containsNull) = ArrayType.defaultConcreteType
    +        (elementType, containsNull)
    +    }
    +    val (rightElementType, rightContainsNull) = right.dataType match {
    +      case ArrayType(elementType, containsNull) => (elementType, containsNull)
    +      case _ =>
    +        val ArrayType(elementType, containsNull) = ArrayType.defaultConcreteType
    +        (elementType, containsNull)
    +    }
    +    copy(function = f(function,
    +      (leftElementType, leftContainsNull) :: (rightElementType, rightContainsNull) :: Nil))
    --- End diff --
    
    If we append `null`s to the shorter array, both of the arguments might be `null`, so we should use `true` for nullabilities of the arguments as @mn-mikke suggested.


---

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


[GitHub] spark pull request #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22031#discussion_r210467535
  
    --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/HigherOrderFunctionsSuite.scala ---
    @@ -396,4 +396,52 @@ class HigherOrderFunctionsSuite extends SparkFunSuite with ExpressionEvalHelper
           map_zip_with(mbb0, mbbn, concat),
           null)
       }
    +
    +  test("ZipWith") {
    +    def zip_with(
    +        left: Expression,
    +        right: Expression,
    +        f: (Expression, Expression) => Expression): Expression = {
    +      val ArrayType(leftT, leftContainsNull) = left.dataType.asInstanceOf[ArrayType]
    +      val ArrayType(rightT, rightContainsNull) = right.dataType.asInstanceOf[ArrayType]
    --- End diff --
    
    nit: we don't need `.asInstanceOf[ArrayType]`?


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/2233/
    Test PASSed.


---

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


[GitHub] spark pull request #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22031#discussion_r210468640
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/DataFrameFunctionsSuite.scala ---
    @@ -2302,6 +2302,76 @@ class DataFrameFunctionsSuite extends QueryTest with SharedSQLContext {
         assert(ex5.getMessage.contains("function map_zip_with does not support ordering on type map"))
       }
     
    +  test("arrays zip_with function - for primitive types") {
    +    val df1 = Seq[(Seq[Integer], Seq[Integer])](
    +      (Seq(9001, 9002, 9003), Seq(4, 5, 6)),
    +      (Seq(1, 2), Seq(3, 4)),
    +      (Seq.empty, Seq.empty),
    +      (null, null)
    +    ).toDF("val1", "val2")
    +    val df2 = Seq[(Seq[Integer], Seq[Long])](
    +      (Seq(1, null, 3), Seq(1L, 2L)),
    +      (Seq(1, 2, 3), Seq(4L, 11L))
    +    ).toDF("val1", "val2")
    +
    +    val expectedValue1 = Seq(
    +      Row(Seq(9005, 9007, 9009)),
    +      Row(Seq(4, 6)),
    +      Row(Seq.empty),
    +      Row(null))
    +    checkAnswer(df1.selectExpr("zip_with(val1, val2, (x, y) -> x + y)"), expectedValue1)
    +
    +    val expectedValue2 = Seq(
    +      Row(Seq(Row(1.0, 1), Row(2.0, null), Row(null, 3))),
    --- End diff --
    
    Why `1.0` or `2.0` instead of `1L` or `2L`?


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/94829/
    Test FAILed.


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/94830/
    Test FAILed.


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/2231/
    Test PASSed.


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Hi @techaddict, 
    Do you have time to continue working on this?
    If you don't have enough time, I can take this over, so please let me know.
    Thanks!


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/94389/
    Test PASSed.


---

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


[GitHub] spark pull request #22031: [TODO][SPARK-23932][SQL] Higher order function zi...

Posted by mn-mikke <gi...@git.apache.org>.
Github user mn-mikke commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22031#discussion_r208399620
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala ---
    @@ -442,3 +442,91 @@ case class ArrayAggregate(
     
       override def prettyName: String = "aggregate"
     }
    +
    +// scalastyle:off line.size.limit
    +@ExpressionDescription(
    +  usage = "_FUNC_(left, right, func) - Merges the two given arrays, element-wise, into a single array using function. If one array is shorter, nulls are appended at the end to match the length of the longer array, before applying function.",
    +  examples = """
    +    Examples:
    +      > SELECT _FUNC_(array(1, 2, 3), array('a', 'b', 'c'), (x, y) -> (y, x));
    +       array(('a', 1), ('b', 3), ('c', 5))
    +      > SELECT _FUNC_(array(1, 2), array(3, 4), (x, y) -> x + y));
    +       array(4, 6)
    +      > SELECT _FUNC_(array('a', 'b', 'c'), array('d', 'e', 'f'), (x, y) -> concat(x, y));
    +       array('ad', 'be', 'cf')
    +  """,
    +  since = "2.4.0")
    +// scalastyle:on line.size.limit
    +case class ArraysZipWith(
    +    left: Expression,
    +    right: Expression,
    +    function: Expression)
    +  extends HigherOrderFunction with CodegenFallback with ExpectsInputTypes {
    +
    +  override def inputs: Seq[Expression] = List(left, right)
    +
    +  override def functions: Seq[Expression] = List(function)
    +
    +  def expectingFunctionType: AbstractDataType = AnyDataType
    +  @transient lazy val functionForEval: Expression = functionsForEval.head
    +
    +  override def inputTypes: Seq[AbstractDataType] = Seq(ArrayType, ArrayType, expectingFunctionType)
    +
    +  override def nullable: Boolean = inputs.exists(_.nullable)
    +
    +  override def dataType: ArrayType = ArrayType(function.dataType, function.nullable)
    +
    +  override def bind(f: (Expression, Seq[(DataType, Boolean)]) => LambdaFunction): ArraysZipWith = {
    +    val (leftElementType, leftContainsNull) = left.dataType match {
    +      case ArrayType(elementType, containsNull) => (elementType, containsNull)
    +      case _ =>
    +        val ArrayType(elementType, containsNull) = ArrayType.defaultConcreteType
    +        (elementType, containsNull)
    +    }
    +    val (rightElementType, rightContainsNull) = right.dataType match {
    +      case ArrayType(elementType, containsNull) => (elementType, containsNull)
    +      case _ =>
    +        val ArrayType(elementType, containsNull) = ArrayType.defaultConcreteType
    +        (elementType, containsNull)
    +    }
    +    copy(function = f(function,
    +      (leftElementType, leftContainsNull) :: (rightElementType, rightContainsNull) :: Nil))
    +  }
    +
    +  @transient lazy val (arr1Var, arr2Var) = {
    +    val LambdaFunction(_,
    +      (arr1Var: NamedLambdaVariable):: (arr2Var: NamedLambdaVariable) :: Nil, _) = function
    +    (arr1Var, arr2Var)
    +  }
    +
    +  override def eval(input: InternalRow): Any = {
    +    val leftArr = left.eval(input).asInstanceOf[ArrayData]
    +    val rightArr = right.eval(input).asInstanceOf[ArrayData]
    +
    +    if (leftArr == null || rightArr == null) {
    --- End diff --
    
    If ```leftArr``` is ```null```, ```right``` doesn't have to be evaluated.


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/94846/
    Test PASSed.


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    @techaddict Could you fix the conflicts please? Thanks!


---

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


[GitHub] spark pull request #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22031#discussion_r210468814
  
    --- Diff: sql/core/src/test/resources/sql-tests/inputs/higher-order-functions.sql ---
    @@ -51,3 +51,12 @@ select exists(ys, y -> y > 30) as v from nested;
     
     -- Check for element existence in a null array
     select exists(cast(null as array<int>), y -> y > 30) as v;
    +
    +-- Zip with array
    +select zip_with(ys, zs, (a, b) -> a + size(b)) as v from nested;
    +
    +-- Zip with array with concat
    +select zip_with(array('a', 'b', 'c'), array('d', 'e', 'f'), (x, y) -> concat(x, y)) as v;
    +
    +-- Zip with array coalesce
    +select zip_with(array('a'), array('d', null, 'f'), (x, y) -> coalesce(x, y)) as v;
    --- End diff --
    
    Can you add a line break at the end of the file?


---

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


[GitHub] spark pull request #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by techaddict <gi...@git.apache.org>.
Github user techaddict commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22031#discussion_r210452329
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala ---
    @@ -442,3 +442,91 @@ case class ArrayAggregate(
     
       override def prettyName: String = "aggregate"
     }
    +
    +// scalastyle:off line.size.limit
    +@ExpressionDescription(
    +  usage = "_FUNC_(left, right, func) - Merges the two given arrays, element-wise, into a single array using function. If one array is shorter, nulls are appended at the end to match the length of the longer array, before applying function.",
    +  examples = """
    +    Examples:
    +      > SELECT _FUNC_(array(1, 2, 3), array('a', 'b', 'c'), (x, y) -> (y, x));
    +       array(('a', 1), ('b', 3), ('c', 5))
    +      > SELECT _FUNC_(array(1, 2), array(3, 4), (x, y) -> x + y));
    +       array(4, 6)
    +      > SELECT _FUNC_(array('a', 'b', 'c'), array('d', 'e', 'f'), (x, y) -> concat(x, y));
    +       array('ad', 'be', 'cf')
    +  """,
    +  since = "2.4.0")
    +// scalastyle:on line.size.limit
    +case class ArraysZipWith(
    +    left: Expression,
    +    right: Expression,
    +    function: Expression)
    +  extends HigherOrderFunction with CodegenFallback with ExpectsInputTypes {
    +
    +  override def inputs: Seq[Expression] = List(left, right)
    +
    +  override def functions: Seq[Expression] = List(function)
    +
    +  def expectingFunctionType: AbstractDataType = AnyDataType
    +  @transient lazy val functionForEval: Expression = functionsForEval.head
    +
    +  override def inputTypes: Seq[AbstractDataType] = Seq(ArrayType, ArrayType, expectingFunctionType)
    +
    +  override def nullable: Boolean = inputs.exists(_.nullable)
    +
    +  override def dataType: ArrayType = ArrayType(function.dataType, function.nullable)
    +
    +  override def bind(f: (Expression, Seq[(DataType, Boolean)]) => LambdaFunction): ArraysZipWith = {
    +    val (leftElementType, leftContainsNull) = left.dataType match {
    +      case ArrayType(elementType, containsNull) => (elementType, containsNull)
    +      case _ =>
    +        val ArrayType(elementType, containsNull) = ArrayType.defaultConcreteType
    +        (elementType, containsNull)
    +    }
    +    val (rightElementType, rightContainsNull) = right.dataType match {
    +      case ArrayType(elementType, containsNull) => (elementType, containsNull)
    +      case _ =>
    +        val ArrayType(elementType, containsNull) = ArrayType.defaultConcreteType
    +        (elementType, containsNull)
    +    }
    +    copy(function = f(function,
    +      (leftElementType, leftContainsNull) :: (rightElementType, rightContainsNull) :: Nil))
    --- End diff --
    
    @mn-mikke @ueshin "both arrays must be the same length" was how zip_with in presto used to work, they've moved to appending nulls and process regardless.


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    **[Test build #94839 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/94839/testReport)** for PR 22031 at commit [`16516ec`](https://github.com/apache/spark/commit/16516ec0862dab60cfbc88683233ed08f6fa5ca5).
     * This patch **fails due to an unknown error code, -9**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    **[Test build #94389 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/94389/testReport)** for PR 22031 at commit [`6f91777`](https://github.com/apache/spark/commit/6f91777de93121d668ff11e7701f449bb4c96337).


---

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


[GitHub] spark pull request #22031: [TODO][SPARK-23932][SQL] Higher order function zi...

Posted by mn-mikke <gi...@git.apache.org>.
Github user mn-mikke commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22031#discussion_r208398313
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala ---
    @@ -442,3 +442,91 @@ case class ArrayAggregate(
     
       override def prettyName: String = "aggregate"
     }
    +
    +// scalastyle:off line.size.limit
    +@ExpressionDescription(
    +  usage = "_FUNC_(left, right, func) - Merges the two given arrays, element-wise, into a single array using function. If one array is shorter, nulls are appended at the end to match the length of the longer array, before applying function.",
    +  examples = """
    +    Examples:
    +      > SELECT _FUNC_(array(1, 2, 3), array('a', 'b', 'c'), (x, y) -> (y, x));
    +       array(('a', 1), ('b', 3), ('c', 5))
    +      > SELECT _FUNC_(array(1, 2), array(3, 4), (x, y) -> x + y));
    +       array(4, 6)
    +      > SELECT _FUNC_(array('a', 'b', 'c'), array('d', 'e', 'f'), (x, y) -> concat(x, y));
    +       array('ad', 'be', 'cf')
    +  """,
    +  since = "2.4.0")
    +// scalastyle:on line.size.limit
    +case class ArraysZipWith(
    +    left: Expression,
    +    right: Expression,
    +    function: Expression)
    +  extends HigherOrderFunction with CodegenFallback with ExpectsInputTypes {
    +
    +  override def inputs: Seq[Expression] = List(left, right)
    +
    +  override def functions: Seq[Expression] = List(function)
    +
    +  def expectingFunctionType: AbstractDataType = AnyDataType
    +  @transient lazy val functionForEval: Expression = functionsForEval.head
    +
    +  override def inputTypes: Seq[AbstractDataType] = Seq(ArrayType, ArrayType, expectingFunctionType)
    +
    +  override def nullable: Boolean = inputs.exists(_.nullable)
    +
    +  override def dataType: ArrayType = ArrayType(function.dataType, function.nullable)
    +
    +  override def bind(f: (Expression, Seq[(DataType, Boolean)]) => LambdaFunction): ArraysZipWith = {
    +    val (leftElementType, leftContainsNull) = left.dataType match {
    --- End diff --
    
    You can utilize ```HigherOrderFunction.arrayArgumentType```.


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    **[Test build #94389 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/94389/testReport)** for PR 22031 at commit [`6f91777`](https://github.com/apache/spark/commit/6f91777de93121d668ff11e7701f449bb4c96337).
     * This patch passes all tests.
     * This patch **does not merge cleanly**.
     * This patch adds no public classes.


---

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


[GitHub] spark pull request #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22031#discussion_r210467959
  
    --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/HigherOrderFunctionsSuite.scala ---
    @@ -396,4 +396,52 @@ class HigherOrderFunctionsSuite extends SparkFunSuite with ExpressionEvalHelper
           map_zip_with(mbb0, mbbn, concat),
           null)
       }
    +
    +  test("ZipWith") {
    +    def zip_with(
    +        left: Expression,
    +        right: Expression,
    +        f: (Expression, Expression) => Expression): Expression = {
    +      val ArrayType(leftT, leftContainsNull) = left.dataType.asInstanceOf[ArrayType]
    +      val ArrayType(rightT, rightContainsNull) = right.dataType.asInstanceOf[ArrayType]
    +      ZipWith(left, right, createLambda(leftT, leftContainsNull, rightT, rightContainsNull, f))
    +    }
    +
    +    val ai0 = Literal.create(Seq(1, 2, 3), ArrayType(IntegerType, containsNull = false))
    +    val ai1 = Literal.create(Seq(1, 2, 3), ArrayType(IntegerType, containsNull = false))
    +    val ai2 = Literal.create(Seq[Integer](1, null, 3), ArrayType(IntegerType, containsNull = true))
    +    val ai3 = Literal.create(Seq[Integer](1, null), ArrayType(IntegerType, containsNull = true))
    +    val ain = Literal.create(null, ArrayType(IntegerType, containsNull = false))
    +
    +    val add: (Expression, Expression) => Expression = (x, y) => x + y
    +    val plusOne: Expression => Expression = x => x + 1
    +
    +    checkEvaluation(zip_with(ai0, ai1, add), Seq(2, 4, 6))
    +    checkEvaluation(zip_with(ai3, ai2, add), Seq(2, null, null))
    +    checkEvaluation(zip_with(ai2, ai3, add), Seq(2, null, null))
    +    checkEvaluation(zip_with(ain, ain, add), null)
    +    checkEvaluation(zip_with(ai1, ain, add), null)
    +    checkEvaluation(zip_with(ain, ai1, add), null)
    +
    +    val as0 = Literal.create(Seq("a", "b", "c"), ArrayType(StringType, containsNull = false))
    +    val as1 = Literal.create(Seq("a", null, "c"), ArrayType(StringType, containsNull = true))
    +    val as2 = Literal.create(Seq("a"), ArrayType(StringType, containsNull = true))
    +    val asn = Literal.create(null, ArrayType(StringType, containsNull = false))
    +
    +    val concat: (Expression, Expression) => Expression = (x, y) => Concat(Seq(x, y))
    +
    +    checkEvaluation(zip_with(as0, as1, concat), Seq("aa", null, "cc"))
    +    checkEvaluation(zip_with(as0, as2, concat), Seq("aa", null, null))
    +
    +    val aai1 = Literal.create(Seq(Seq(1, 2, 3), null, Seq(4, 5)),
    +      ArrayType(ArrayType(IntegerType, containsNull = false), containsNull = true))
    +    val aai2 = Literal.create(Seq(Seq(1, 2, 3)),
    +      ArrayType(ArrayType(IntegerType, containsNull = false), containsNull = true))
    +    checkEvaluation(
    +      zip_with(aai1, aai2, (a1, a2) =>
    +          Cast(zip_with(transform(a1, plusOne), transform(a2, plusOne), add), StringType)),
    --- End diff --
    
    nit: indent


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/2241/
    Test PASSed.


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/94392/
    Test PASSed.


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    **[Test build #94845 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/94845/testReport)** for PR 22031 at commit [`16516ec`](https://github.com/apache/spark/commit/16516ec0862dab60cfbc88683233ed08f6fa5ca5).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    **[Test build #94833 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/94833/testReport)** for PR 22031 at commit [`0342ed9`](https://github.com/apache/spark/commit/0342ed934e65c13c43081f464503800118383a44).


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    **[Test build #94846 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/94846/testReport)** for PR 22031 at commit [`2388130`](https://github.com/apache/spark/commit/23881303c16d30f321dd9a923379e5c6e37aad31).


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Jenkins, retest this please.


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    **[Test build #94846 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/94846/testReport)** for PR 22031 at commit [`2388130`](https://github.com/apache/spark/commit/23881303c16d30f321dd9a923379e5c6e37aad31).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Build finished. Test PASSed.


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/94391/
    Test PASSed.


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Merged build finished. Test FAILed.


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Merged build finished. Test FAILed.


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Merged build finished. Test FAILed.


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/1927/
    Test PASSed.


---

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


[GitHub] spark pull request #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22031#discussion_r210467721
  
    --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/HigherOrderFunctionsSuite.scala ---
    @@ -396,4 +396,52 @@ class HigherOrderFunctionsSuite extends SparkFunSuite with ExpressionEvalHelper
           map_zip_with(mbb0, mbbn, concat),
           null)
       }
    +
    +  test("ZipWith") {
    +    def zip_with(
    +        left: Expression,
    +        right: Expression,
    +        f: (Expression, Expression) => Expression): Expression = {
    +      val ArrayType(leftT, leftContainsNull) = left.dataType.asInstanceOf[ArrayType]
    +      val ArrayType(rightT, rightContainsNull) = right.dataType.asInstanceOf[ArrayType]
    +      ZipWith(left, right, createLambda(leftT, leftContainsNull, rightT, rightContainsNull, f))
    +    }
    +
    +    val ai0 = Literal.create(Seq(1, 2, 3), ArrayType(IntegerType, containsNull = false))
    +    val ai1 = Literal.create(Seq(1, 2, 3), ArrayType(IntegerType, containsNull = false))
    --- End diff --
    
    What's the difference between `ai0` and `ai1`?


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    @techaddict Thanks! I look forward to the update.


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/94833/
    Test PASSed.


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    **[Test build #94839 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/94839/testReport)** for PR 22031 at commit [`16516ec`](https://github.com/apache/spark/commit/16516ec0862dab60cfbc88683233ed08f6fa5ca5).


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark pull request #22031: [TODO][SPARK-23932][SQL] Higher order function zi...

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22031#discussion_r208445048
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala ---
    @@ -442,3 +442,91 @@ case class ArrayAggregate(
     
       override def prettyName: String = "aggregate"
     }
    +
    +// scalastyle:off line.size.limit
    +@ExpressionDescription(
    +  usage = "_FUNC_(left, right, func) - Merges the two given arrays, element-wise, into a single array using function. If one array is shorter, nulls are appended at the end to match the length of the longer array, before applying function.",
    +  examples = """
    +    Examples:
    +      > SELECT _FUNC_(array(1, 2, 3), array('a', 'b', 'c'), (x, y) -> (y, x));
    +       array(('a', 1), ('b', 3), ('c', 5))
    +      > SELECT _FUNC_(array(1, 2), array(3, 4), (x, y) -> x + y));
    +       array(4, 6)
    +      > SELECT _FUNC_(array('a', 'b', 'c'), array('d', 'e', 'f'), (x, y) -> concat(x, y));
    +       array('ad', 'be', 'cf')
    +  """,
    +  since = "2.4.0")
    +// scalastyle:on line.size.limit
    +case class ArraysZipWith(
    +    left: Expression,
    +    right: Expression,
    +    function: Expression)
    +  extends HigherOrderFunction with CodegenFallback with ExpectsInputTypes {
    +
    +  override def inputs: Seq[Expression] = List(left, right)
    +
    +  override def functions: Seq[Expression] = List(function)
    +
    +  def expectingFunctionType: AbstractDataType = AnyDataType
    +  @transient lazy val functionForEval: Expression = functionsForEval.head
    +
    +  override def inputTypes: Seq[AbstractDataType] = Seq(ArrayType, ArrayType, expectingFunctionType)
    +
    +  override def nullable: Boolean = inputs.exists(_.nullable)
    +
    +  override def dataType: ArrayType = ArrayType(function.dataType, function.nullable)
    +
    +  override def bind(f: (Expression, Seq[(DataType, Boolean)]) => LambdaFunction): ArraysZipWith = {
    +    val (leftElementType, leftContainsNull) = left.dataType match {
    +      case ArrayType(elementType, containsNull) => (elementType, containsNull)
    +      case _ =>
    +        val ArrayType(elementType, containsNull) = ArrayType.defaultConcreteType
    +        (elementType, containsNull)
    +    }
    +    val (rightElementType, rightContainsNull) = right.dataType match {
    +      case ArrayType(elementType, containsNull) => (elementType, containsNull)
    +      case _ =>
    +        val ArrayType(elementType, containsNull) = ArrayType.defaultConcreteType
    +        (elementType, containsNull)
    +    }
    +    copy(function = f(function,
    +      (leftElementType, leftContainsNull) :: (rightElementType, rightContainsNull) :: Nil))
    +  }
    +
    +  @transient lazy val (arr1Var, arr2Var) = {
    +    val LambdaFunction(_,
    +      (arr1Var: NamedLambdaVariable):: (arr2Var: NamedLambdaVariable) :: Nil, _) = function
    +    (arr1Var, arr2Var)
    +  }
    --- End diff --
    
    nit: the following should work:
    
    ```scala
    @transient lazy val LambdaFunction(_,
      Seq(leftElemVar: NamedLambdaVariable, rightElemVar: NamedLambdaVariable), _) = function
    ```


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    **[Test build #94392 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/94392/testReport)** for PR 22031 at commit [`c7e2dee`](https://github.com/apache/spark/commit/c7e2dee7cf48efd28d764fdd543bf366d65fcfa5).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark pull request #22031: [TODO][SPARK-23932][SQL] Higher order function zi...

Posted by mn-mikke <gi...@git.apache.org>.
Github user mn-mikke commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22031#discussion_r208403145
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala ---
    @@ -442,3 +442,91 @@ case class ArrayAggregate(
     
       override def prettyName: String = "aggregate"
     }
    +
    +// scalastyle:off line.size.limit
    +@ExpressionDescription(
    +  usage = "_FUNC_(left, right, func) - Merges the two given arrays, element-wise, into a single array using function. If one array is shorter, nulls are appended at the end to match the length of the longer array, before applying function.",
    +  examples = """
    +    Examples:
    +      > SELECT _FUNC_(array(1, 2, 3), array('a', 'b', 'c'), (x, y) -> (y, x));
    +       array(('a', 1), ('b', 3), ('c', 5))
    +      > SELECT _FUNC_(array(1, 2), array(3, 4), (x, y) -> x + y));
    +       array(4, 6)
    +      > SELECT _FUNC_(array('a', 'b', 'c'), array('d', 'e', 'f'), (x, y) -> concat(x, y));
    +       array('ad', 'be', 'cf')
    +  """,
    +  since = "2.4.0")
    +// scalastyle:on line.size.limit
    +case class ArraysZipWith(
    +    left: Expression,
    +    right: Expression,
    +    function: Expression)
    +  extends HigherOrderFunction with CodegenFallback with ExpectsInputTypes {
    +
    +  override def inputs: Seq[Expression] = List(left, right)
    +
    +  override def functions: Seq[Expression] = List(function)
    +
    +  def expectingFunctionType: AbstractDataType = AnyDataType
    +  @transient lazy val functionForEval: Expression = functionsForEval.head
    +
    +  override def inputTypes: Seq[AbstractDataType] = Seq(ArrayType, ArrayType, expectingFunctionType)
    +
    +  override def nullable: Boolean = inputs.exists(_.nullable)
    +
    +  override def dataType: ArrayType = ArrayType(function.dataType, function.nullable)
    +
    +  override def bind(f: (Expression, Seq[(DataType, Boolean)]) => LambdaFunction): ArraysZipWith = {
    +    val (leftElementType, leftContainsNull) = left.dataType match {
    +      case ArrayType(elementType, containsNull) => (elementType, containsNull)
    +      case _ =>
    +        val ArrayType(elementType, containsNull) = ArrayType.defaultConcreteType
    +        (elementType, containsNull)
    +    }
    +    val (rightElementType, rightContainsNull) = right.dataType match {
    +      case ArrayType(elementType, containsNull) => (elementType, containsNull)
    +      case _ =>
    +        val ArrayType(elementType, containsNull) = ArrayType.defaultConcreteType
    +        (elementType, containsNull)
    +    }
    +    copy(function = f(function,
    +      (leftElementType, leftContainsNull) :: (rightElementType, rightContainsNull) :: Nil))
    --- End diff --
    
    If you want to support different size of input arrays (The jira ticket says: _"Both arrays must be the same length."_), what about the scenario when one array is empty and the second has elements? Shouldn't we use ```true``` instead of  ```leftContainsNull``` and ```rightContainsNull```?


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/1924/
    Test PASSed.


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/2230/
    Test PASSed.


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by techaddict <gi...@git.apache.org>.
Github user techaddict commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Hi @ueshin I will update the PR tommorow


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    **[Test build #94830 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/94830/testReport)** for PR 22031 at commit [`92cb34a`](https://github.com/apache/spark/commit/92cb34af9c1e5742d9fa21f677645daea029bfd6).


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark pull request #22031: [TODO][SPARK-23932][SQL] Higher order function zi...

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22031#discussion_r208444793
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala ---
    @@ -442,3 +442,91 @@ case class ArrayAggregate(
     
       override def prettyName: String = "aggregate"
     }
    +
    +// scalastyle:off line.size.limit
    +@ExpressionDescription(
    +  usage = "_FUNC_(left, right, func) - Merges the two given arrays, element-wise, into a single array using function. If one array is shorter, nulls are appended at the end to match the length of the longer array, before applying function.",
    +  examples = """
    +    Examples:
    +      > SELECT _FUNC_(array(1, 2, 3), array('a', 'b', 'c'), (x, y) -> (y, x));
    +       array(('a', 1), ('b', 3), ('c', 5))
    +      > SELECT _FUNC_(array(1, 2), array(3, 4), (x, y) -> x + y));
    +       array(4, 6)
    +      > SELECT _FUNC_(array('a', 'b', 'c'), array('d', 'e', 'f'), (x, y) -> concat(x, y));
    +       array('ad', 'be', 'cf')
    +  """,
    +  since = "2.4.0")
    +// scalastyle:on line.size.limit
    +case class ArraysZipWith(
    +    left: Expression,
    +    right: Expression,
    +    function: Expression)
    +  extends HigherOrderFunction with CodegenFallback with ExpectsInputTypes {
    +
    +  override def inputs: Seq[Expression] = List(left, right)
    +
    +  override def functions: Seq[Expression] = List(function)
    +
    +  def expectingFunctionType: AbstractDataType = AnyDataType
    --- End diff --
    
    We don't need to define this?


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    **[Test build #94845 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/94845/testReport)** for PR 22031 at commit [`16516ec`](https://github.com/apache/spark/commit/16516ec0862dab60cfbc88683233ed08f6fa5ca5).


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    **[Test build #94829 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/94829/testReport)** for PR 22031 at commit [`d6c44a6`](https://github.com/apache/spark/commit/d6c44a637ae7bc52865644048b372316da15ccd5).


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/1926/
    Test PASSed.


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    **[Test build #94392 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/94392/testReport)** for PR 22031 at commit [`c7e2dee`](https://github.com/apache/spark/commit/c7e2dee7cf48efd28d764fdd543bf366d65fcfa5).


---

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


[GitHub] spark issue #22031: [TODO][SPARK-23932][SQL] Higher order function zip_with

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    **[Test build #94829 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/94829/testReport)** for PR 22031 at commit [`d6c44a6`](https://github.com/apache/spark/commit/d6c44a637ae7bc52865644048b372316da15ccd5).
     * This patch **fails Spark unit tests**.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `case class ArraysZipWith(left: Expression, right: Expression, function: Expression)`


---

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


[GitHub] spark issue #22031: [SPARK-23932][SQL] Higher order function zip_with

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/22031
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/94839/
    Test FAILed.


---

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