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

[jira] [Commented] (CALCITE-4861) Optimisation of chained cast calls can lead to unexpected behaviour

    [ https://issues.apache.org/jira/browse/CALCITE-4861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17518041#comment-17518041 ] 

Julian Hyde commented on CALCITE-4861:
--------------------------------------

JdbcTest isn't the best place for tests. Maybe in SqlOperatorTest or a .iq file.

It would be good to test all combinations of types, especially exact numeric types including DECIMAL.

> Optimisation of chained cast calls can lead to unexpected behaviour
> -------------------------------------------------------------------
>
>                 Key: CALCITE-4861
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4861
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>            Reporter: Marios Trivyzas
>            Priority: Minor
>              Labels: pull-request-available
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Simplification of Cast chained calls can lead to unexpected behaviour:
> CAST(CAST(CAST(123456 AS TINYINT) AS INT) AS BIGINT)
> is simplified to 
> {noformat}
> CAST(123456 AS BIGINT){noformat}
> 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.1#820001)