You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/03/28 11:30:00 UTC

[GitHub] [spark] HyukjinKwon commented on a change in pull request #24232: [SPARK-27297] [SQL] Add higher order functions to scala API

HyukjinKwon commented on a change in pull request #24232: [SPARK-27297] [SQL] Add higher order functions to scala API
URL: https://github.com/apache/spark/pull/24232#discussion_r269958689
 
 

 ##########
 File path: sql/core/src/main/scala/org/apache/spark/sql/functions.scala
 ##########
 @@ -3316,6 +3316,141 @@ object functions {
     ArrayExcept(col1.expr, col2.expr)
   }
 
+  private def expressionFunction(f: Column => Column)
+  : Expression => Expression =
+    x => f(Column(x)).expr
+
+  private def expressionFunction(f: (Column, Column) => Column)
+  : (Expression, Expression) => Expression =
+    (x, y) => f(Column(x), Column(y)).expr
+
+  private def expressionFunction(f: (Column, Column, Column) => Column)
+  : (Expression, Expression, Expression) => Expression =
+    (x, y, z) => f(Column(x), Column(y), Column(z)).expr
+
+  /**
+   * Returns an array of elements after applying a tranformation to each element
+   * in the input array.
+   *
+   * @group collection_funcs
+   */
+  def transform(column: Column, f: Column => Column): Column = withExpr {
+    HigherOrderUtils.transform(column.expr, expressionFunction(f))
+  }
+
+  /**
+   * Returns an array of elements after applying a tranformation to each element
+   * in the input array.
+   *
+   * @group collection_funcs
+   */
+  def transform(column: Column, f: (Column, Column) => Column): Column = withExpr {
+    HigherOrderUtils.transform(column.expr, expressionFunction(f))
+  }
+
+  /**
+   * Returns whether a predicate holds for one or more elements in the array.
+   *
+   * @group collection_funcs
+   */
+  def exists(column: Column, f: Column => Column): Column = withExpr {
 
 Review comment:
   But how do we support this in Java?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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