[
https://issues.apache.org/jira/browse/CALCITE-3828?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17045283#comment-17045283
]
Ruben Q L edited comment on CALCITE-3828 at 2/26/20 9:42 AM:
-------------------------------------------------------------
MergeJoin algorithm assumes that inputs are sorted in ascending order, with
nulls last (see EnumerableMergeJoinRule), so when reaching a null key on the
left / right side should mean that we are done.
was (Author: rubenql):
MergeJoin algorithm assumes that inputs sorted in ascending order, with nulls
last (see EnumerableMergeJoinRule), so when reaching a null key on the left /
right side should mean that we are done.
> 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
> Labels: pull-request-available
> Time Spent: 10m
> Remaining Estimate: 0h
>
> 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)