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

EnumerableDefaults#nestedLoopJoin returns duplicates for JoinType.SEMI

    XMLWordPrintableJSON

    Details

      Description

      The issue can be reproduced by adding the following test to EnumerablesTest.java:

      @Test public void testNestedLoopSemiJoin() {
        assertThat(
          EnumerableDefaults.nestedLoopJoin(DEPTS, EMPS, (d, e) -> d.deptno == e.deptno,
                (d, e) -> d.toString(), JoinType.SEMI).toList().toString(),
          equalTo("[Dept(20, Sales)]"));
      }
      

      This test performs a "DEPT semi-join EMP" (i.e. select all departments which have at least one employee):

      SELECT * FROM DEPT
      WHERE EXISTS (SELECT 1 FROM EMP WHERE DEPT.DEPTNO = EMP.DEPTNO)
      

      This semi-join query must not return duplicates, however the test returns them (it returns "Sales" two times because it has two employees, but this is wrong, it should be returned just once):

      Expected: "[Dept(20, Sales)]"
       but: was "[Dept(20, Sales), Dept(20, Sales)]"
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                rubenql Ruben Q L
                Reporter:
                rubenql Ruben Q L
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h