You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Ruben Q L (Jira)" <ji...@apache.org> on 2020/02/26 09:13:00 UTC

[jira] [Updated] (CALCITE-3828) MergeJoin throws NPE in case of null keys

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

Ruben Q L updated CALCITE-3828:
-------------------------------
    Description: 
Problem can be reproduced with the following test (to be added to EnumerablesTest.java):
{code}
@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)]"));
}
{code}

which throws a NPE inside EnumerableDefaults#MergeJoinEnumerator when trying to compare null keys:
{code}
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)
{code}

  was:
Problem can be reproduced with the following test (to be added to EnumerablesTest.java):
{code}
@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)]"));
}
{code}

which throws a NPE inside EnumerableDefaults#MergeJoinEnumerator when trying to compare null keys:
{code}
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)
{code}


> MergeJoin throws NPE in case of null keys
> -----------------------------------------
>
>                 Key: CALCITE-3828
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3828
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.21.0
>            Reporter: Ruben Q L
>            Assignee: Ruben Q L
>            Priority: Major
>
> Problem can be reproduced with the following test (to be added to EnumerablesTest.java):
> {code}
> @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)]"));
> }
> {code}
> which throws a NPE inside EnumerableDefaults#MergeJoinEnumerator when trying to compare null keys:
> {code}
> 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)
> {code}



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