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

Benchao Li commented on FLINK-27407:
------------------------------------

[~luoyuxia] There is a discussion in Calcite: 
[https://lists.apache.org/thread/hlj500zyvf6ydg21zsjhwjpwt727snoq]
It may be related to your issue, and the other similar issue you created 
recently.

Put it shortly, Calcite has implicit type conversion feature for compare 
operations, even if you do not enable TypeCoercion.

> Exception of "unable to find common type of Boolean and Char(4)" will be 
> thrown when RexSarg contains "Boolean" and "Char(4)"
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: FLINK-27407
>                 URL: https://issues.apache.org/jira/browse/FLINK-27407
>             Project: Flink
>          Issue Type: Bug
>            Reporter: luoyuxia
>            Priority: Major
>
> For Flink SQL, the following sql can be excuted:
> {code:java}
> create table t1 (id bigint, name string, is_normal_play boolean);
> select * from t1 where (name = '111') and is_normal_play = 'true'; {code}
> But the following sql will throw exception:
> {code:java}
> select * from t1 where (name = '111' or name = '222') and is_normal_play = 
> 'true' {code}
> After some debuging, I found the reason is the expression "(name = '111' or 
> name = '222') and is_normal_play = 'true' "  will be simplified with each 
> operand simplified to SEARCH operator.
> So is_normal_play = 'true' will be converted to SEARCH(is_normal_play, 
> 'true');
> Then during code gen for Search operator in 
> "SearchOperatorGen#generateSearch", it will try to find the common tyoe 
> between Boolean and Char(4) coresponding to is_normal_play, 'true'. But 
> there's no any implicit cast between  Boolean and Char(4), so the exception 
> is thrown 
> "
> org.apache.flink.table.planner.codegen.CodeGenException: Unable to find 
> common type of GeneratedExpression(field$10,isNull$10,,BOOLEAN,None) and 
> Sarg[_UTF-16LE'true']:CHAR(4) CHARACTER SET "UTF-16LE".
> "



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to