When Calcite generates enumerable code, it represents each SQL DECIMAL value as a scaled Java Long. (Just as it represents SQL DATE values as Java Integer.)
If you want that ‘raw’ value, ask for a BigDecimal. That’s how DECIMAL values are stored at prepare time (i.e. inside the RexLiteral). Julian > On Dec 8, 2021, at 3:27 PM, Jihoon Son <[email protected]> wrote: > > Hi all, > > I am using the 'RexLiteral.getValueAs()' method to convert a literal to a > java object. I recently noticed that this method returns an unscaled value > when you convert a decimal literal to a Long object. As a result, this > method returns '1230' for the decimal literal of '123.0'. The code piece in > question can be found in > https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/rex/RexLiteral.java#L1051-L1054. > I checked the git commit associated with this behavior, but could not find > anything from it. I would like to understand this behavior better. Can > someone explain the rationale for this? > > Thanks, > Jihoon
