[ 
https://issues.apache.org/jira/browse/CALCITE-3411?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated CALCITE-3411:
------------------------------------
    Labels: pull-request-available  (was: )

> Incorrect code generated for BigDecimal ConstantExpression
> ----------------------------------------------------------
>
>                 Key: CALCITE-3411
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3411
>             Project: Calcite
>          Issue Type: Bug
>    Affects Versions: 1.21.0
>            Reporter: Feng Zhu
>            Assignee: Feng Zhu
>            Priority: Major
>              Labels: pull-request-available
>
> In current implementation
> {code:java}
> Expressions.constant("104", BigDecimal.class) -> new 
> java.math.BigDecimal(104L)
> Expressions.constant("1000", BigDecimal.class) -> new 
> java.math.BigDecimal(1L, -3){code}
> However, in *java.math.BigDecimal*, there is no constructor:
> {code:java}
> java.math.BigDecimal(long exact, int scale) {code}
> Instead we should call method
> {code:java}
>  java.math.BigDecimal.valueOf(long exact, int scale){code}
> h4. *Why this issue did not exposed before?*
> *BlockBuilder* conducts optimizations that can bury this issue.
> For example, when we disable the optimization. 
> _MaterializationTest#testAggregateMaterializationAggregateFuncs11_ will 
> produce the code below. However, it can't pass the compilation.
> {code:java}
> final long v = org.apache.calcite.runtime.SqlFunctions.floor(853763696000L, 
> ((Long) new java.math.BigDecimal(1L, -3)).longValue());{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to