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

duan xiong commented on CALCITE-4861:
-------------------------------------

Yes. But  
{code:java}
CAST(543.21 AS DECIMAL(7, 3)){code}
In Postgresql. It padding values "0" when doesn't have enough decimal number.
 It returns 543.210.
 In Calcite, It returns 543.21(no padding).


 And another problem needs to confirm:
{code:java}
SELECT CAST(543.21 AS DECIMAL(7, 7)){code}
 In PostgreSQL:
{noformat}
[22003] ERROR: numeric field overflow 详细:A field with precision 7, scale 7 must 
round to an absolute value less than 1.{noformat}
In Calcite:  It returns 543.21.

 

> 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
>
> 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.3.4#803005)

Reply via email to