sorry for late reply cuz I'm on my vocation until next Monday,then I'll
read all you comments carefully,really appreciate your work, thanks.

On Thu, May 23, 2019, 04:27 Julian Hyde (JIRA) <[email protected]> wrote:

>
>     [
> https://issues.apache.org/jira/browse/CALCITE-3065?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16846211#comment-16846211
> ]
>
> Julian Hyde commented on CALCITE-3065:
> --------------------------------------
>
> The basic idea is that you call {{getLiteralAs}} with a class {{c}}, then
> the value that comes back is an instance of {{c}}. This is a nice simple
> contract.
>
> If {{c}} is {{int.class}}, then it is impossible to fulfill that contract.
> A {{java.lang.Integer}} is not an instance of {{int.class}}. (No java
> object is an instance of {{int.class}}.)
>
> (Scala's type system may deceive you about that. But this is a Java API.)
>
> As I said already, you can fix this by adding one line of code to your
> program. That is better, in my opinion, than making the contract more
> complicated.
>
> Regarding decimals. You are correct that Calcite internally stores all
> numeric literals using {{BigDecimal}}. This is because {{BigDecimal}} can
> represent every possible numeric literal value, and can do so without
> losing precision. (If you store say 0.1 as a double, it will get rounded.)
> If you want to consume the value as a {{java.math.BigDecimal}}, or as a
> {{java.lang.Number}}, or as an {{java.lang.Integer}}, or as a
> {{java.lang.Float}}, you can do that, and the API will convert the value to
> the type that you choose. But you cannot ask for {{int}}, because we cannot
> give you an {{int}}.
>
> > RexLiteral#getValueAs should consider primitive type
> > ----------------------------------------------------
> >
> >                 Key: CALCITE-3065
> >                 URL: https://issues.apache.org/jira/browse/CALCITE-3065
> >             Project: Calcite
> >          Issue Type: Improvement
> >          Components: core
> >            Reporter: Jiatao Tao
> >            Priority: Major
> >              Labels: pull-request-available
> >         Attachments: image-2019-05-13-12-04-36-365.png,
> image-2019-05-17-08-23-52-735.png
> >
> >          Time Spent: 40m
> >  Remaining Estimate: 0h
> >
> > !image-2019-05-13-12-04-36-365.png!
>
>
>
> --
> This message was sent by Atlassian JIRA
> (v7.6.3#76005)
>

Reply via email to