GitHub user hvanhovell opened a pull request:
https://github.com/apache/spark/pull/16063
[SPARK-18622][SQL] Remove TypeCoercion rules for Average and Sum aggregate
functions
## What changes were proposed in this pull request?
Spark currently has special analyzer rules for the 'Sum' and 'Average'
aggregate functions. These rules promote the inputs of these aggregate
functions to the largest type to prevent overflows. There are two issues with
these rules:
- They are redundant because these particular aggregate functions do their
own casting internally.
- The aggregates are not in an `unresolved` state before these rules. This
causes a weird interaction with `WidenSetOperationTypes` (which has an implicit
assumption that the underlying schema does not change anymore), the union would
get widened and then the rules defined in `FunctionArgumentConversion` would
change the underlying schema.
This PR removes these rules from `FunctionArgumentConversion`.
## How was this patch tested?
Added (regression) tests to SQLQueryTestSuite's `union.sql`.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/hvanhovell/spark SPARK-18622
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/16063.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 #16063
----
commit 7596b5aaffa39b5ded5e2ea5a90e0d7d751973b2
Author: Herman van Hovell <[email protected]>
Date: 2016-11-29T19:18:46Z
Fix type coercion for sum aggregate
----
---
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]