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

Sean Broeder commented on CALCITE-4861:
---------------------------------------

[~julianhyde] Thank you for the valuable input.  I will relocate the tests to 
SqlOperatorTest in a following patch that includes changes for deprecated APIs 
I didn't detect locally.

I was aware this patch didn't address truncation of DECIMAL types, but I wanted 
to get some knowledgable eyes on the handling of INT_TYPES in case there was a 
better or preferred way to address the overflow.

> 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)

Reply via email to