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

xuyangzhong commented on CALCITE-4806:
--------------------------------------

In Mysql "select cast(1.1 as signed)=1" is 1.

In calcite "CAST(1.1 AS INT) = 1" is false.

And CAST(1.1 AS bigint) = 1 and CAST(1.1 AS smallint) = 1 are also false.

It seems that when cast a double,float(with a decimal point) to a int, 
smallint...(with no decimal point), it will cause FALSE. I think it is caused 
by RexBuilder.makeCastin which removes the cast and 
StandardConvertletTable.consistentType gets the common type between INTEGER and 
INTEGER, and 1.1 compareTo 1 is false.

> When simplifying 'equals', the data type will be ignore
> -------------------------------------------------------
>
>                 Key: CALCITE-4806
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4806
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: xuyangzhong
>            Priority: Major
>
> the sql is following:
> {code:java}
> // code placeholder
> select cast(1.1 as int) = cast (1 as int){code}
> In SQLite the result is 1 and in postgreSQL the result is true.
> But in calcite the result is false.
> The bug is in RexSimplify and 1.1 and 1 are all converted to 
> java.lang.Comparable, and 1.1 doesn't equal to 1. It ignores the source data 
> type. The literal 1.1 should be cast to 1(int) first.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to