Mihai Budiu created CALCITE-7840:
------------------------------------

             Summary: 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


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