GitHub user maropu opened a pull request:
https://github.com/apache/spark/pull/11269
[SPARK-13363][SQL] Support Aggregator in DataFrame
Support user-defined `Aggregator`s in DataFrame.
Currently, the code below does not work because of an unresolved error in
`CheckAnalysis`.
```
val simpleSum = new SqlAggregator[Int, Int, Int] {
def zero: Int = 0 // The initial value.
def reduce(b: Int, a: Int) = b + a // Add an element to the running
total
def merge(b1: Int, b2: Int) = b1 + b2 // Merge intermediate values.
def finish(b: Int) = b // Return the final result.
}.toColumn
val df = sc.makeRDD(1 to 3).map(i => (i, i)).toDF("k", "v")
df.groupBy("k").agg(simpleSum).show
```
This pr fix this and add tests according to `DatasetAggregatorSuite`.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/maropu/spark SupportAggregatorInDF
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/11269.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 #11269
----
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]