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

IndexOutOfBoundsException in ProjectFilterTransposeRule when executing SELECT COUNT(*)

    XMLWordPrintableJSON

Details

    Description

      The exception is raised by many tests in DruidAdapterIT.

      What they all have in common is a query of the following form:

      SELECT COUNT(*) FROM ...
      

      where the query projects only a single column.

      The stacktrace for DruidAdapterIT#testExpressionsFilterWithExtract is the following.

      Caused by: java.lang.RuntimeException: Error while applying rule DruidProjectFilterTransposeRule, args [rel#226:LogicalProject.NONE.[](input=RelSubset#50), rel#83:BindableFilter.BINDABLE.[](input=RelSubset#18,condition==(CAST(+(/(-(EXTRACT(FLAG(MONTH), $0), 1), 3), 1)):INTEGER NOT NULL, 1)), rel#1:DruidQuery.BINDABLE.[](table=[foodmart, foodmart],intervals=[1900-01-09T00:00:00.000Z/2992-01-10T00:00:00.000Z])]
      	at org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:235)
      	at org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:631)
      	at org.apache.calcite.tools.Programs.lambda$standard$3(Programs.java:283)
      	at org.apache.calcite.tools.Programs$SequenceProgram.run(Programs.java:343)
      	at org.apache.calcite.prepare.Prepare.optimize(Prepare.java:189)
      	at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:320)
      	at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:231)
      	at org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:637)
      	at org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:501)
      	at org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:471)
      	at org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:229)
      	at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:550)
      	at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:675)
      	at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:156)
      	... 28 more
      Caused by: java.lang.IndexOutOfBoundsException: index (0) must be less than size (0)
      	at com.google.common.base.Preconditions.checkElementIndex(Preconditions.java:310)
      	at com.google.common.base.Preconditions.checkElementIndex(Preconditions.java:293)
      	at com.google.common.collect.RegularImmutableList.get(RegularImmutableList.java:67)
      	at org.apache.calcite.rel.rules.ProjectFilterTransposeRule.onMatch(ProjectFilterTransposeRule.java:102)
      	at org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:208)
      	... 41 more
      
      

      It is regression that must be solved before the release.

      Attachments

        Issue Links

          Activity

            People

              danny0405 Danny Chen
              zabetak Stamatis Zampetakis
              Votes:
              0 Vote for this issue
              Watchers:
              3 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 - 20m
                  20m