GitHub user kaspersorensen opened a pull request:
https://github.com/apache/metamodel/pull/128
Demonstrated issue with AVG function and fixed/adapted in JDBC module
I was looking at METAMODEL-193 because I found it a bit strange that it was
reported that e.g. `AVG(an-integer-column)` would always return an integer.
After some digging around I realized that this is common RDBMS behaviour. But
common or not, it is inconsistent with all the other MetaModel connectors.
So I thought to fix it so that there is consistency: I made it so that the
`AVG` function will return a double no matter what. This requires the native
SQL to be rewritten slightly to make the RDBMS pick it up. So my fix was to
rewrite it into `AVG(1.0*an-integer-column)`. Granted this is a pretty dirty
rewrite. So I am curious for review remarks and open for improvement ideas.
Note that this PR does NOT fix METAMODEL-193, but it fixes one of the
use-cases causing that issue to be relevant at all.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/kaspersorensen/metamodel
bug/inconsistent-avg-return-type
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/metamodel/pull/128.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 #128
----
commit aacdaaab260e005411e90aaf8c4bcc3c8d23909e
Author: Kasper Sørensen <[email protected]>
Date: 2016-09-06T03:56:24Z
Demonstrated issue with AVG function and fixed/adapted in JDBC module
----
---
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.
---