[ 
https://issues.apache.org/jira/browse/CALCITE-7840?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Mihai Budiu resolved CALCITE-7840.
----------------------------------
    Fix Version/s: 1.43.0
       Resolution: Fixed

Fixed in 
[https://github.com/apache/calcite/commit/7cd4022a1162448bfbca14e8da7e8451a5aac4a2]

Thank you for the review [~xuzifu666] 

> REAL literals should be represented with reduced precision
> ----------------------------------------------------------
>
>                 Key: CALCITE-7840
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7840
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.42.0
>            Reporter: Mihai Budiu
>            Assignee: Mihai Budiu
>            Priority: Minor
>              Labels: pull-request-available
>             Fix For: 1.43.0
>
>
> When casting a numeric literal to a REAL value Calcite still stores the value 
> using a Java Double. That's fine, but the stored value should be first 
> computed using the REAL precision, and then saved as a DOUBLE.
> This is pretty subtle. This is the result of a quidem test today:
> {code:java}
> values (cast(0.1e0 as real) = cast(0.1 as real),
>   cast(cast(0.1e0 as real) as double) = cast(cast(0.1 as real) as double),
>   cast(0.1e0 as real) = 0.1e0);
> +--------+--------+--------+
> | EXPR$0 | EXPR$1 | EXPR$2 |
> +--------+--------+--------+
> | false  | false  | true   |
> +--------+--------+--------+
> (1 row) {code}
> This is the expected result:
> {code:java}
> +--------+--------+--------+
> | EXPR$0 | EXPR$1 | EXPR$2 |
> +--------+--------+--------+
> | true   | true   | false  |
> +--------+--------+--------+ {code}
> (Postgres at least agrees with the last result, with some qualifications 
> regarding how Postgres types literals)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to