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

NullPointerException with merge join

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.26.0
    • 1.27.0
    • core
    • None

    Description

      Using the sqlline tool with the Elasticsearch adapter:

      Error: Error while executing SQL "select a._MAP from "testindex" a left outer join "testindex" b on b._MAP['_id'] = a._MAP['department._ref'] where a._MAP['_id'] = '0000000A15'": null (state=,code=0)
      java.sql.SQLException: Error while executing SQL "select a._MAP from "testindex" a left outer join "testindex" b on b._MAP['_id'] = a._MAP['department._ref'] where a._MAP['_id'] = '0000000A15'": null
       at org.apache.calcite.avatica.Helper.createException(Helper.java:56)
       at org.apache.calcite.avatica.Helper.createException(Helper.java:41)
       at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:163)
       at org.apache.calcite.avatica.AvaticaStatement.execute(AvaticaStatement.java:217)
       at sqlline.Commands.executeSingleQuery(Commands.java:1054)
       at sqlline.Commands.execute(Commands.java:1003)
       at sqlline.Commands.sql(Commands.java:967)
       at sqlline.SqlLine.dispatch(SqlLine.java:734)
       at sqlline.SqlLine.begin(SqlLine.java:541)
       at sqlline.SqlLine.start(SqlLine.java:267)
       at sqlline.SqlLine.main(SqlLine.java:206)
      Caused by: java.lang.NullPointerException
       at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:878)
       at com.google.common.collect.ImmutableList$Builder.addAll(ImmutableList.java:823)
       at org.apache.calcite.rel.metadata.RelMdCollation.mergeJoin(RelMdCollation.java:466)
       at org.apache.calcite.rel.metadata.RelMdCollation.collations(RelMdCollation.java:157)
       at GeneratedMetadataHandler_Collation.collations_$(Unknown Source)
       at GeneratedMetadataHandler_Collation.collations(Unknown Source)
       at GeneratedMetadataHandler_Collation.collations_$(Unknown Source)
       at GeneratedMetadataHandler_Collation.collations(Unknown Source)
       at org.apache.calcite.rel.metadata.RelMetadataQuery.collations(RelMetadataQuery.java:543)
       at org.apache.calcite.rel.metadata.RelMdCollation.project(RelMdCollation.java:277)
       at org.apache.calcite.rel.metadata.RelMdCollation.calc(RelMdCollation.java:270)
       at org.apache.calcite.adapter.enumerable.EnumerableCalc.lambda$create$0(EnumerableCalc.java:99)
       at org.apache.calcite.plan.RelTraitSet.replaceIfs(RelTraitSet.java:242)
       at org.apache.calcite.adapter.enumerable.EnumerableCalc.create(EnumerableCalc.java:98)
       at org.apache.calcite.adapter.enumerable.EnumerableProjectToCalcRule.onMatch(EnumerableProjectToCalcRule.java:50)
       at org.apache.calcite.plan.AbstractRelOptPlanner.fireRule(AbstractRelOptPlanner.java:333)
       at org.apache.calcite.plan.hep.HepPlanner.applyRule(HepPlanner.java:542)
       at org.apache.calcite.plan.hep.HepPlanner.applyRules(HepPlanner.java:407)
       at org.apache.calcite.plan.hep.HepPlanner.executeInstruction(HepPlanner.java:243)
       at org.apache.calcite.plan.hep.HepInstruction$RuleInstance.execute(HepInstruction.java:127)
       at org.apache.calcite.plan.hep.HepPlanner.executeProgram(HepPlanner.java:202)
       at org.apache.calcite.plan.hep.HepPlanner.findBestExp(HepPlanner.java:189)
       at org.apache.calcite.tools.Programs.lambda$of$0(Programs.java:173)
       at org.apache.calcite.tools.Programs$SequenceProgram.run(Programs.java:331)
       at org.apache.calcite.prepare.Prepare.optimize(Prepare.java:166)
       at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:297)
       at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:208)
       at org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:642)
       at org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:508)
       at org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:478)
       at org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:231)
       at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:556)
       at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:675)
       at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:156)
       ... 8 more
      

      (Looks like this happens during the planning phase, since it also happens with "explain plan for".)

      After some debugging, it seems this is because my Elasticsearch mapping excludes certain attributes from _source by default, including "department". So the field is searchable, but comes back as null. The query will never work; but it should perhaps not throw an NPE.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              atombender Alexander Staubo
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: