calcite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Feng Zhu (Jira)" <>
Subject [jira] [Created] (CALCITE-3411) Incorrect code generated for BigDecimal ConstantExpression
Date Mon, 14 Oct 2019 14:24:00 GMT
Feng Zhu created CALCITE-3411:

             Summary: Incorrect code generated for BigDecimal ConstantExpression
                 Key: CALCITE-3411
             Project: Calcite
          Issue Type: Bug
    Affects Versions: 1.21.0
            Reporter: Feng Zhu
            Assignee: Feng Zhu

In current implementation
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:
java.math.BigDecimal(long exact, int scale) {code}
Instead we should call method
 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.
final long v = org.apache.calcite.runtime.SqlFunctions.floor(853763696000L, ((Long) new java.math.BigDecimal(1L,

This message was sent by Atlassian Jira

View raw message