GitHub user ueshin opened a pull request:
https://github.com/apache/spark/pull/21982
[SPARK-23909][SQL] Add aggregate function.
## What changes were proposed in this pull request?
This pr adds `aggregate` function which 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.
```sql
> SELECT aggregate(array(1, 2, 3), (acc, x) -> acc + x);
6
> SELECT aggregate(array(1, 2, 3), (acc, x) -> acc + x, acc -> acc * 10);
60
```
## How was this patch tested?
Added tests.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/ueshin/apache-spark
issues/SPARK-23911/aggregate
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/21982.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 #21982
----
commit 26bf37960a1534da8e2119181dce5794e3b48172
Author: Takuya UESHIN <ueshin@...>
Date: 2018-08-03T06:25:08Z
Add `ArrayAggregate`.
----
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]