Re: Question about RexLiteral.getValueAs() returning an unscaled long for decimal literals

2021-12-08 Thread Jihoon Son
I see. Thank you for your answers. On Wed, Dec 8, 2021 at 4:41 PM Julian Hyde wrote: > Yes, that might work. > > > On Dec 8, 2021, at 4:35 PM, Jihoon Son wrote: > > > > Julian, thanks for your answer. > > > > The case I'm looking into is a function that accepts a numeric and > returns > > a num

Re: Question about RexLiteral.getValueAs() returning an unscaled long for decimal literals

2021-12-08 Thread Julian Hyde
Yes, that might work. > On Dec 8, 2021, at 4:35 PM, Jihoon Son wrote: > > Julian, thanks for your answer. > > The case I'm looking into is a function that accepts a numeric and returns > a numeric such as 'floor(123.0)'. In this case, the literal is created > using `rexBuilder.makeLiteral(123.0

Re: Question about RexLiteral.getValueAs() returning an unscaled long for decimal literals

2021-12-08 Thread Jihoon Son
Julian, thanks for your answer. The case I'm looking into is a function that accepts a numeric and returns a numeric such as 'floor(123.0)'. In this case, the literal is created using `rexBuilder.makeLiteral(123.0, typeFactory.createSqlType(SqlTypeName.INTEGER), true)`. This creates a literal that

Re: Question about RexLiteral.getValueAs() returning an unscaled long for decimal literals

2021-12-08 Thread Julian Hyde
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). Jul

Question about RexLiteral.getValueAs() returning an unscaled long for decimal literals

2021-12-08 Thread Jihoon Son
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 pie