[
https://issues.apache.org/jira/browse/CALCITE-5838?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17845447#comment-17845447
]
Mihai Budiu commented on CALCITE-5838:
--------------------------------------
I think this issue is invalid.
Indeed, Calcite does not specify the result type for an aggregate function.
maybe it should.
I think that currently the rule is that the result type is the same as the
argument type.
See the discussion for https://issues.apache.org/jira/browse/CALCITE-6324
So I will close this issue
> derive wrong decimal divide type
> --------------------------------
>
> Key: CALCITE-5838
> URL: https://issues.apache.org/jira/browse/CALCITE-5838
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.34.0
> Reporter: pengfei.zhan
> Priority: Major
>
> Given a table metadata structure as follows:
> {code:sql}
> create table `tbl_test`(`CRR` decimal(38,2), `DT` varchar(4096)) ROW FORMAT
> DELIMITED FIELDS TERMINATED BY '\t';
> {code}
> If the following query is executed,
> {code:sql}
> select sum(CRR_0/1000000000.02) from (select sum(CRR) as CRR_0 from tbl_test
> where DT='20230705') T1
> {code}
> The RexCall CRR_0/1000000000.02 derived a decimal type of decimal(38, 0). I
> referred the derived type in spark, but it gives decimal(38, 4). It looks
> like the inferred type is more reasonable.
> [hive doc |
> https://cwiki.apache.org/confluence/download/attachments/27362075/Hive_Decimal_Precision_Scale_Support.pdf]
> [sql server doc | https://msdn.microsoft.com/en-us/library/ms190476.aspx]
--
This message was sent by Atlassian Jira
(v8.20.10#820010)