xuyangzhong commented on a change in pull request #2555:
URL: https://github.com/apache/calcite/pull/2555#discussion_r719010727



##########
File path: 
core/src/main/java/org/apache/calcite/sql/type/SqlTypeCoercionRule.java
##########
@@ -202,7 +202,8 @@ private SqlTypeCoercionRule(Map<SqlTypeName, 
ImmutableSet<SqlTypeName>> map) {
         coerceRules.copyValues(SqlTypeName.BOOLEAN)
             .add(SqlTypeName.CHAR)
             .add(SqlTypeName.VARCHAR)
-            .addAll(SqlTypeName.NUMERIC_TYPES)
+            .addAll(SqlTypeName.INT_TYPES)
+            .addAll(SqlTypeName.APPROX_TYPES)

Review comment:
       About this bug I create a JIRA yesterday(in 
https://issues.apache.org/jira/browse/CALCITE-4810) before this pr.
   I tested the sql "tester.checkBoolean("cast(cast(0.0 as double) as 
boolean)", Boolean.FALSE);" in master where i didn't apply my change and it 
threw the same exception just like you says.
   I tried to find the reason and add the message into [CALCITE-4810]. It seems 
the bug that these two behavoirs codegen and constant simplifying is not 
unified.
   I think your suggestion that avoids casting from float, real, double and 
decimal to boolean is reasonable and this also can solve this problem of 
inconsistent behavior. And more importantly, it follows the SQL standard.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to