Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.21.0
-
None
Description
In current implementation
Expressions.constant("104", BigDecimal.class) -> new java.math.BigDecimal(104L) Expressions.constant("1000", BigDecimal.class) -> new java.math.BigDecimal(1L, -3)
However, in java.math.BigDecimal, there is no constructor:
java.math.BigDecimal(long exact, int scale)
Instead we should call method
java.math.BigDecimal.valueOf(long exact, int scale)
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, -3)).longValue());
Attachments
Issue Links
- links to