[jira] Commented: (JDO-643) avg return type
[ https://issues.apache.org/jira/browse/JDO-643?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12999575#comment-12999575 ] Michael Bouschen commented on JDO-643: -- Here is the proposed spec change on page 177 of the 3.0 version of the spec. Replace the second and third paragraph under the headline Aggregate Types by: Sum returns Long for integral types and the field’s type for other Number types (BigDecimal, Big- Integer, Float, and Double). Avg returns Double. Sum and avg are invalid if applied to non-Number types. Min, and max return the type of the expression. avg return type --- Key: JDO-643 URL: https://issues.apache.org/jira/browse/JDO-643 Project: JDO Issue Type: Bug Components: specification, tck Affects Versions: JDO 2 maintenance release 2 Reporter: Guido Anzuoni Assignee: Michael Bouschen Fix For: JDO 3 maintenance release 1 Attachments: JDO-643.patch Aggregate type specification at page 175 claims that avg(expression) return type is the same of the enclosed expression. This is wrong from a strictly mathematical point of view. In fact, if you select an avg on an int field member the result is truncated. The result type should always be double. -- This message is automatically generated by JIRA. - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (JDO-643) avg return type
[ https://issues.apache.org/jira/browse/JDO-643?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12978801#action_12978801 ] Andy Jefferson commented on JDO-643: Patch applied. DN 2.2.2 (not yet released, but downloadable as a nightly build), and 3.x abide by this JDO spec change avg return type --- Key: JDO-643 URL: https://issues.apache.org/jira/browse/JDO-643 Project: JDO Issue Type: Bug Components: specification Affects Versions: JDO 2 maintenance release 2 Reporter: Guido Anzuoni Assignee: Michael Bouschen Fix For: JDO 3 maintenance release 1 Attachments: JDO-643.patch Aggregate type specification at page 175 claims that avg(expression) return type is the same of the enclosed expression. This is wrong from a strictly mathematical point of view. In fact, if you select an avg on an int field member the result is truncated. The result type should always be double. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.
[jira] Commented: (JDO-643) avg return type
[ https://issues.apache.org/jira/browse/JDO-643?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12978509#action_12978509 ] Michael Bouschen commented on JDO-643: -- I agree there is no good reason to differ from JPA here, which means avg(expressin) would alwas return Double. I think the patch JDO-643.patch is good to be checked in. avg return type --- Key: JDO-643 URL: https://issues.apache.org/jira/browse/JDO-643 Project: JDO Issue Type: Bug Components: specification Affects Versions: JDO 2 maintenance release 2 Reporter: Guido Anzuoni Assignee: Michael Bouschen Fix For: JDO 3 maintenance release 1 Attachments: JDO-643.patch Aggregate type specification at page 175 claims that avg(expression) return type is the same of the enclosed expression. This is wrong from a strictly mathematical point of view. In fact, if you select an avg on an int field member the result is truncated. The result type should always be double. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.
[jira] Commented: (JDO-643) avg return type
[ https://issues.apache.org/jira/browse/JDO-643?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12978512#action_12978512 ] Craig L Russell commented on JDO-643: - I agree. With the patch, this should now be just a specification (and RI) issue. avg return type --- Key: JDO-643 URL: https://issues.apache.org/jira/browse/JDO-643 Project: JDO Issue Type: Bug Components: specification Affects Versions: JDO 2 maintenance release 2 Reporter: Guido Anzuoni Assignee: Michael Bouschen Fix For: JDO 3 maintenance release 1 Attachments: JDO-643.patch Aggregate type specification at page 175 claims that avg(expression) return type is the same of the enclosed expression. This is wrong from a strictly mathematical point of view. In fact, if you select an avg on an int field member the result is truncated. The result type should always be double. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.
[jira] Commented: (JDO-643) avg return type
[ https://issues.apache.org/jira/browse/JDO-643?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12972584#action_12972584 ] Andy Jefferson commented on JDO-643: If the datastore indeed does evaluate it as double (equivalent) then your comment makes sense. JPA doesn't allow specification of candidate instances and hence allow in-memory evaluation whereas JDO does. That is one case where avg(BigInteger) returning BigDecimal makes sense. If it's the only case then it likely shouldn't effect a change to the general rule. avg return type --- Key: JDO-643 URL: https://issues.apache.org/jira/browse/JDO-643 Project: JDO Issue Type: Bug Components: specification Affects Versions: JDO 2 maintenance release 2 Reporter: Guido Anzuoni Assignee: Michael Bouschen Fix For: JDO 3 maintenance release 1 Attachments: JDO-643.patch Aggregate type specification at page 175 claims that avg(expression) return type is the same of the enclosed expression. This is wrong from a strictly mathematical point of view. In fact, if you select an avg on an int field member the result is truncated. The result type should always be double. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.
[jira] Commented: (JDO-643) avg return type
[ https://issues.apache.org/jira/browse/JDO-643?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12970786#action_12970786 ] Andy Jefferson commented on JDO-643: My vote would go to short, int, long, double, float should return double BigInteger, BigDecimal should return BigDecimal avg return type --- Key: JDO-643 URL: https://issues.apache.org/jira/browse/JDO-643 Project: JDO Issue Type: Bug Components: specification Affects Versions: JDO 2 maintenance release 2 Reporter: Guido Anzuoni Assignee: Michael Bouschen Fix For: JDO 3 maintenance release 1 Aggregate type specification at page 175 claims that avg(expression) return type is the same of the enclosed expression. This is wrong from a strictly mathematical point of view. In fact, if you select an avg on an int field member the result is truncated. The result type should always be double. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.
[jira] Commented: (JDO-643) avg return type
[ https://issues.apache.org/jira/browse/JDO-643?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12970806#action_12970806 ] Michael Bouschen commented on JDO-643: -- I agree, avg(expression) should return - Double for integral types (byte, short, int, long), float, double and their wrapper classes - BigDecimal for BigInteger and BigDecimal Two remarks: - We need to point out that this is an incompatible change, meaning a valid JDO 3.0 query might run into a RuntimeException. - JPA always uses Double as return type avg return type --- Key: JDO-643 URL: https://issues.apache.org/jira/browse/JDO-643 Project: JDO Issue Type: Bug Components: specification Affects Versions: JDO 2 maintenance release 2 Reporter: Guido Anzuoni Assignee: Michael Bouschen Fix For: JDO 3 maintenance release 1 Aggregate type specification at page 175 claims that avg(expression) return type is the same of the enclosed expression. This is wrong from a strictly mathematical point of view. In fact, if you select an avg on an int field member the result is truncated. The result type should always be double. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.
[jira] Commented: (JDO-643) avg return type
[ https://issues.apache.org/jira/browse/JDO-643?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12970635#action_12970635 ] Craig L Russell commented on JDO-643: - I'd like to see this changed as well. Can someone write up what the return type should be for all of the numeric types that JDO supports? I don't think it's obvious that double is the right type for average of BigInteger or BigDecimal. And what about float? avg return type --- Key: JDO-643 URL: https://issues.apache.org/jira/browse/JDO-643 Project: JDO Issue Type: Bug Components: specification Affects Versions: JDO 2 maintenance release 2 Reporter: Guido Anzuoni Assignee: Michael Bouschen Fix For: JDO 3 maintenance release 1 Aggregate type specification at page 175 claims that avg(expression) return type is the same of the enclosed expression. This is wrong from a strictly mathematical point of view. In fact, if you select an avg on an int field member the result is truncated. The result type should always be double. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.