[
https://issues.apache.org/jira/browse/FLINK-27407?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17527884#comment-17527884
]
luoyuxia commented on FLINK-27407:
----------------------------------
[~godfreyhe] Could you please help have a look? Is it a problem?
>From myside, it may not be a problem as it's expected that it's not allowed to
>compare between string and boolean implicitly.
Actually, we find such case when do some work for Hive dialect compatibility
[FLINK-27379|https://issues.apache.org/jira/browse/FLINK-27379]. Although it's
not supported to cast boolean to string implicitly in
[Hive|[https://cwiki.apache.org/confluence/display/hive/languagemanual+types#LanguageManualTypes-AllowedImplicitConversions]]
, but's it'll actually call Hive's GenericUDFOPEqual for "=" operator which
will try best to do comparison including type converion explicitly.
> 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)