Thank you for reply. What I want is a getValue() method which returns
exactly the value of literal based on its type. You are right that I can
use literal.getValueAs(Double.class) to get a Double value, but maybe it's
better to provide a method like what I say. What do you think?

Julian Hyde <[email protected]> 于2020年3月5日周四 下午2:20写道:

> As the java doc says, RexLiteral.getValue2 returns values in the form that
> the calculator builder needs them. That may not be the form that you need
> them. In which case, don’t use that method.
>
> If you want a Double, have you tried literal.getValueAs(Double.class)?
>
> (We don’t tend to use Float and Double much because when we’re compiling
> queries we can’t afford any loss of precision. If the user typed 1.1 we
> want exactly 1.1, whereas Decimal might be something like 1.000000000987.)
>
> > On Mar 4, 2020, at 9:43 PM, Xiangwei Wei <[email protected]> wrote:
> >
> > In RexLiteral.getValue2(), it treats Decimal just by `return
> > getValueAs(Long.class);`.
> > In this instance, we can't get a correct double/float value because it's
> > considered as Decimal type here. Is this a problem or is there a reason
> > here?
> >
> > --
> > Best,
> > Xiangwei Wei
>
>

-- 
Best,
Xiangwei Wei

Reply via email to