Shuo Cheng created FLINK-22063:
----------------------------------

             Summary: Lookup Join outputs wrong results for some scenario
                 Key: FLINK-22063
                 URL: https://issues.apache.org/jira/browse/FLINK-22063
             Project: Flink
          Issue Type: New Feature
          Components: Table SQL / API
    Affects Versions: 1.12.2
            Reporter: Shuo Cheng


Reproduce the bug as following:

In LookupJoinITCase, given the sql 

{code:sql}
SELECT 
        T.id, T.len, D.id, T.content, D.name 
FROM src AS T JOIN user_table for system_time as of T.proctime AS D 
ON T.id = D.id and cast(T.len as bigint) = D.id
{code}

the following execution plan is generated:

{code:java}
LegacySink(name=[DataStreamTableSink], fields=[id, len, id0, content, name])
+- Calc(select=[id, len, id0, content, name])
   +- LookupJoin(table=[**], joinType=[InnerJoin], async=[false], 
lookup=[id=len0], select=[id, len, content, len0, id, name])
      +- Calc(select=[id, len, content, CAST(len) AS len0])
         +- TableSourceScan(table=[[**]], fields=[id, len, content])
{code}

As we can see, the condition `T.id = D.id` is lost, so a wrong result may be 
produced.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to