You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Chunwei Lei (Jira)" <ji...@apache.org> on 2022/04/27 06:33:00 UTC

[jira] [Resolved] (CALCITE-4861) Optimization of chained CAST calls can lead to unexpected behavior

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

Chunwei Lei resolved CALCITE-4861.
----------------------------------
    Fix Version/s: 1.31.0
         Assignee: Benchao Li
       Resolution: Fixed

Fixed in [https://github.com/apache/calcite/commit/4ee98e0c0625e5adc7b2eed3e60702ee744c435d|https://github.com/apache/calcite/commit/4ee98e0c0625e5adc7b2eed3e60702ee744c435d.]. Thank you for the PR, [~libenchao] !

> Optimization of chained CAST calls can lead to unexpected behavior
> ------------------------------------------------------------------
>
>                 Key: CALCITE-4861
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4861
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>            Reporter: Marios Trivyzas
>            Assignee: Benchao Li
>            Priority: Minor
>              Labels: pull-request-available
>             Fix For: 1.31.0
>
>          Time Spent: 2.5h
>  Remaining Estimate: 0h
>
> Simplification of Cast chained calls can lead to unexpected behaviour:
> {code}CAST(CAST(CAST(123456 AS TINYINT) AS INT) AS BIGINT){code}
> is simplified to 
> {code}
> CAST(123456 AS BIGINT){code}
> and returns *123456* with *BIGINT* data type, where the first inner cast as TINYINT should already fail because the value is out of range.
> For example, for PostgreSQL:
> {noformat}
> postgres=# select 123456::smallint::int::bigint;
> ERROR: smallint out of range{noformat}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)