Github user ueshin commented on a diff in the pull request:
https://github.com/apache/spark/pull/21982#discussion_r208493152
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala
---
@@ -270,3 +278,90 @@ case class ArrayFilter(
override def prettyName: String = "filter"
}
+
+/**
+ * Applies a binary operator to a start value and all elements in the
array.
+ */
+@ExpressionDescription(
+ usage =
+ """
+ _FUNC_(expr, start, merge, finish) - Applies a binary operator to an
initial state and all
+ elements in the array, and reduces this to a single state. The final
state is converted
+ into the final result by applying a finish function.
+ """,
+ examples = """
+ Examples:
+ > SELECT _FUNC_(array(1, 2, 3), (acc, x) -> acc + x);
--- End diff --
Oops, sorry, we need the second argument as an initial value.
```sql
SELECT aggregate(array(1, 2, 3), 0, (acc, x) -> acc + x);
```
I'll submit a follow-up pr soon.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]