You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "luoyuxia (Jira)" <ji...@apache.org> on 2022/04/26 04:39:00 UTC
[jira] [Updated] (FLINK-27407) Exception of "unable to find common type of Boolean and Char(4)" will be thrown when RexSarg contains "Boolean" and "Char(4)"
[ https://issues.apache.org/jira/browse/FLINK-27407?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
luoyuxia updated FLINK-27407:
-----------------------------
Description:
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".
"
was:
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".
"
.
> 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)