[
https://issues.apache.org/jira/browse/CALCITE-5604?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17703639#comment-17703639
]
Shuo Cheng edited comment on CALCITE-5604 at 3/22/23 12:17 PM:
---------------------------------------------------------------
Hi [~loganzheng], As ANSI SQL 2011 declared, the current behavior is correct.
{noformat}
If AVG is specified and DT is exact numeric, then the declared type of the
result is an implementation-defined exact numeric type with precision not less
than the precision of DT and scale
not less than the scale of DT.{noformat}
You can explain more specifically why do you think the return type inferred for
AVG should be float.
was (Author: icshuo):
Hi [~loganzheng], As Ansi SQL 2011 declared, the current behavior is correct.
{noformat}
If AVG is specified and DT is exact numeric, then the declared type of the
result is an implementation-defined exact numeric type with precision not less
than the precision of DT and scale
not less than the scale of DT.{noformat}
You can explain more specifically why do you think the return type inferred for
AVG should be float.
> Avg function should infer correct data type
> -------------------------------------------
>
> Key: CALCITE-5604
> URL: https://issues.apache.org/jira/browse/CALCITE-5604
> Project: Calcite
> Issue Type: Bug
> Components: core
> Reporter: logan.zheng
> Priority: Minor
> Labels: patch
>
> Currently,when the avg input is int type,the return type is int type, but the
> correct type is float
> RelDataTypeSystemImpl
> {code:java}
> // code placeholder
> @Override public RelDataType deriveAvgAggType(RelDataTypeFactory typeFactory,
> RelDataType argumentType) {
> return argumentType;
> } {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)