[
https://issues.apache.org/jira/browse/CALCITE-6074?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Sergey Nuyanzin closed CALCITE-6074.
------------------------------------
Resolved in release 1.37.0 (2024-05-06)
> The size of REAL, DOUBLE, and FLOAT is not consistent
> -----------------------------------------------------
>
> Key: CALCITE-6074
> URL: https://issues.apache.org/jira/browse/CALCITE-6074
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.35.0
> Reporter: Mihai Budiu
> Assignee: Mihai Budiu
> Priority: Minor
> Labels: pull-request-available
> Fix For: 1.37.0
>
>
> This stems from the review of CALCITE-6052
> Which one is 8 bytes and which one is 4 bytes?
> The intent seems to be that DOUBLE and FLOAT are synonyms, both using 8
> bytes, (which is very weird for Java users), and REAL is 4 bytes.
> But an audit of the code shows that:
> In AggregateNode.maxMinClass:
> {code:java}
> case FLOAT:
> return max ? MaxFloat.class : MinFloat.class;
> case DOUBLE:
> case REAL:
> return max ? MaxDouble.class : MinDouble.class;
> {code}
> In VisitorDataContext:
> {code:java}
> case DOUBLE:
> return Pair.of(index, rexLiteral.getValueAs(Double.class));
> case REAL:
> return Pair.of(index, rexLiteral.getValueAs(Float.class));
> {code}
> (no case for FLOAT)
> In RelMdSize:
> {code:java}
> case FLOAT:
> case REAL:
> ....
> return 4d;
> {code}
> in RelDataTypeFactoryImpl:
> {code:java}
> case REAL:
> return createSqlType(SqlTypeName.DECIMAL, 14, 7);
> case FLOAT:
> return createSqlType(SqlTypeName.DECIMAL, 14, 7);
> case DOUBLE:
> // the default max precision is 19, so this is actually DECIMAL(19, 15)
> // but derived system can override the max precision/scale.
> return createSqlType(SqlTypeName.DECIMAL, 30, 15);
> {code}
> The reference.md itself seems to be wrong:
> {code}
> | REAL, FLOAT | 4 byte floating point | 6 decimal digits precision.
> | DOUBLE | 8 byte floating point | 15 decimal digits precision.
> {code}
> and there are many more I haven't even checked!
--
This message was sent by Atlassian Jira
(v8.20.10#820010)