GitHub user hvanhovell opened a pull request:
https://github.com/apache/spark/pull/15348
[SPARK-17758][SQL] Last returns wrong result in case of empty partition
## What changes were proposed in this pull request?
The result of the `Last` function can be wrong when the last partition
processed is empty. It can return `null` instead of the expected value. For
example, this can happen when we process partitions in the following order:
```
- Partition 1 [Row1, Row2]
- Partition 2 [Row3]
- Partition 3 []
```
In this case the `Last` function will currently return a null, instead of
the value of `Row3`.
This PR fixes this by adding a `valueSet` flag to the `Last` function.
## How was this patch tested?
We only used end to end tests for `DeclarativeAggregateFunction`s. I have
added an evaluator for these functions so we can tests them in catalyst. I have
added a `LastTestSuite` to test the `Last` aggregate function.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/hvanhovell/spark SPARK-17758
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/15348.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 #15348
----
commit 1f0bb1b10558545c29f717162fc3a59855cc96b6
Author: Herman van Hovell <[email protected]>
Date: 2016-10-04T03:02:47Z
Fix Last aggregate function.
commit 893fff5fa9f229643907f23a548f4e32564b2bb0
Author: Herman van Hovell <[email protected]>
Date: 2016-10-04T17:56:06Z
Add tests for Last aggregate function
----
---
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]