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

MergeJoin throws NPE in case of null keys

    XMLWordPrintableJSON

    Details

      Description

      Problem can be reproduced with the following test (to be added to EnumerablesTest.java):

      @Test public void testMergeJoinWithNullKeys() {
        assertThat(
        EnumerableDefaults.mergeJoin(
          Linq4j.asEnumerable(
            Arrays.asList(
              new Emp(30, "Fred"),
              new Emp(20, "Sebastian"),
              new Emp(30, "Theodore"),
              new Emp(20, "Theodore"),
              new Emp(40, null),
              new Emp(30, null))),
          Linq4j.asEnumerable(
            Arrays.asList(
              new Dept(15, "Marketing"),
              new Dept(20, "Sales"),
              new Dept(30, "Theodore"),
              new Dept(40, null))),
          e -> e.name,
          d -> d.name,
          (v0, v1) -> v0 + ", " + v1, false, false).toList().toString(),
        equalTo("[Emp(30, Theodore), Dept(30, Theodore),"
          + " Emp(20, Theodore), Dept(30, Theodore)]"));
      }
      

      which throws a NPE inside EnumerableDefaults#MergeJoinEnumerator when trying to compare null keys:

      java.lang.NullPointerException
      	at java.lang.String.compareTo(String.java:1155)
      	at java.lang.String.compareTo(String.java:111)
      	at org.apache.calcite.linq4j.EnumerableDefaults$MergeJoinEnumerator.advance(EnumerableDefaults.java:3861)
      

        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 - 1h 50m
                  1h 50m