Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-3170

ANTI join on conditions push down generates wrong plan

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

      Description

      create table A (a int, b int);
      create table B (c int, d int);
      insert into A values (1, 1);
      insert into A values (2, 2);

      sql:

      select * from A where A.a not in (select B.c from B where A.b > 1);
      

      the equivalent logical tree:

      LogicalProject(a=[$0], b=[$1])
      +- LogicalProject(a=[$0], b=[$1])
         +- LogicalJoin(condition=[AND(OR(=($0, $3), IS NULL($0), IS NULL($3)), $2)], joinType=[anti])
            :- LogicalProject(a=[$0], b=[$1], $f2=[>($1, 1)])
            :  +- LogicalTableScan(table=[[A]])
            +- LogicalProject(c=[$0])
               +- LogicalFilter(condition=[true])
                  +- LogicalTableScan(table=[[B]])
      

      the correct result is: (1, 1), (2, 2)
      while if the predicate ($2 in join condition) is pushed into left side, the result is (2, 2) which is incorrect.

        Attachments

        Issue Links

          Activity

            People

            • Assignee:
              danny0405 Danny Chen
              Reporter:
              godfreyhe godfrey he

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 2h 20m
                2h 20m

                  Issue deployment