[ 
https://issues.apache.org/jira/browse/FLINK-27402?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Flink Jira Bot updated FLINK-27402:
-----------------------------------
    Labels: pull-request-available stale-assigned  (was: pull-request-available)

I am the [Flink Jira Bot|https://github.com/apache/flink-jira-bot/] and I help 
the community manage its development. I see this issue is assigned but has not 
received an update in 30 days, so it has been labeled "stale-assigned".
If you are still working on the issue, please remove the label and add a 
comment updating the community on your progress.  If this issue is waiting on 
feedback, please consider this a reminder to the committer/reviewer. Flink is a 
very active project, and so we appreciate your patience.
If you are no longer working on the issue, please unassign yourself so someone 
else may work on it.


> Unexpected boolean expression simplification  for AND expression 
> -----------------------------------------------------------------
>
>                 Key: FLINK-27402
>                 URL: https://issues.apache.org/jira/browse/FLINK-27402
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / Planner
>            Reporter: luoyuxia
>            Assignee: Yunhong Zheng
>            Priority: Major
>              Labels: pull-request-available, stale-assigned
>
> Flink supports to compare between string and boolean, so the following sql 
> can work fine
>  
> {code:java}
> create table (c1 int, c2 string);
> select * from c2 = true;
> {code}
> But the following sql will throw excpetion 
>  
> {code:java}
> select * from c1 = 1 and c2 = true; {code}
> The reason it that Flink will try to simplify BOOLEAN expressions if possible 
> in 
> "c1 = 1 and c2 = true".
> So "c2 = true" will be simplified to "c2" by the following code in Flink:
>  
> {code:java}
> RexSimplify#simplifyAnd2ForUnknownAsFalse
> // Simplify BOOLEAN expressions if possible
> while (term.getKind() == SqlKind.EQUALS) {
>     RexCall call = (RexCall) term;
>     if (call.getOperands().get(0).isAlwaysTrue()) {
>         term = call.getOperands().get(1);
>         terms.set(i, term);
>         continue;
>     } else if (call.getOperands().get(1).isAlwaysTrue()) {
>         term = call.getOperands().get(0);
>         terms.set(i, term);
>         continue;
>     }
>     break;
> } {code}
> So the expression will be reduced to ""c1 = 1 and c2". But AND requries both 
> sides are boolean expression and c2 is not a boolean expression for it 
> actually is a string.
> Then the exception "Boolean expression type expected" is thrown.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to