GitHub user egraldlo opened a pull request: https://github.com/apache/spark/pull/978
do best to avoid overflowing in function avg since we define the return data type of avg() to DoubleType, I think we can do our best to extend the scope to avoid the overflowing, so I think we can transform the datatype to DoubleType before sum. You can merge this pull request into a Git repository by running: $ git pull https://github.com/egraldlo/spark function-avg Alternatively you can review and apply these changes as the patch at: https://github.com/apache/spark/pull/978.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 #978 ---- commit 1153f752b0c3e9cb27250eb842c83a3f84e00362 Author: egraldlo <egral...@gmail.com> Date: 2014-06-05T08:31:43Z do best to avoid overflowing in function avg(). commit d414cd70a719e6ace60b588da65457300970a8f1 Author: egraldlo <egral...@gmail.com> Date: 2014-06-05T08:42:36Z fommatting issues ---- --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. ---