You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Oliver Lee (Jira)" <ji...@apache.org> on 2024/11/01 00:08:00 UTC
[jira] [Comment Edited] (CALCITE-6662) RelJson.rangePointFromJson cannot create Double numerics
[ https://issues.apache.org/jira/browse/CALCITE-6662?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17894734#comment-17894734 ]
Oliver Lee edited comment on CALCITE-6662 at 11/1/24 12:07 AM:
---------------------------------------------------------------
An example of what I encountered is this JSON:
{literal={rangeSet=[[closed, 0.05139999999999949, 0.05500100000000055]], nullAs=UNKNOWN}, type={type=DOUBLE, nullable=false}}
While the RangeSet has type information and we know it's a double, rangeEndpointFromJson would create the Range with lower=BigDecimal.of(0.05139999999999949) and upper=BigDecimal.of(0.05500100000000055) and this is what causes the error later in RexLiteral.init
was (Author: JIRAUSER297744):
An example of what I encountered is this JSON:
{quote} \{literal={rangeSet=[[closed, 0.05139999999999949, 0.05500100000000055]], nullAs=UNKNOWN}, type=\\{type=DOUBLE, nullable=false}}
{quote}
While the RangeSet has type information and we know it's a double, rangeEndpointFromJson would create the Range with lower=BigDecimal.of(0.05139999999999949) and upper=BigDecimal.of(0.05500100000000055) and this is what causes the error later in RexLiteral.init
> RelJson.rangePointFromJson cannot create Double numerics
> --------------------------------------------------------
>
> Key: CALCITE-6662
> URL: https://issues.apache.org/jira/browse/CALCITE-6662
> Project: Calcite
> Issue Type: Task
> Reporter: Oliver Lee
> Assignee: Oliver Lee
> Priority: Minor
> Labels: pull-request-available
>
> Following CALCITE-2067, RexLiteral has more accurate validation between using exact numerics vs approximate numerics to create RexLiterals.
> [RelJson.rangeEndPointFromJson|https://github.com/apache/calcite/blob/2e99d5118efbba21c87e7da08b8359ce296e138d/core/src/main/java/org/apache/calcite/rel/externalize/RelJson.java#L940] however only creates all numerics using BigDecimal, and this causes errors to be thrown when deserializing rel jsons [here|https://github.com/apache/calcite/blob/2e99d5118efbba21c87e7da08b8359ce296e138d/core/src/main/java/org/apache/calcite/rex/RexLiteral.java#L234].
>
> I believe the fix would be to allow rangeEndPointFromJson to attempt to cast to `Double` first, check if it is the same value prior to casting, otherwise continue to cast as BigDecimal, which we use for exact numerics.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)