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

Presence of an empty aggregation should not lead to Exceptions

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.18.0
    • Component/s: None
    • Labels:
      None

      Description

      After some transformations if an "empty" aggregation is present; LoptOptimizeJoinRule may bump into an array index violation.

      Original query is complicated; but this small RelMetadataTest testcase reproduces the root cause.

        @Test public void testEmptyAggregateNotCausesException() throws Exception {
          final FrameworkConfig config = RelBuilderTest.config().build();
          final RelBuilder builder = RelBuilder.create(config);
      
          RelMetadataQuery mq = RelMetadataQuery.instance();
          RelNode agg = builder
              .scan("EMP")
              .aggregate(builder.groupKey(), Collections.<AggCall> emptyList()).build();
          mq.getTableOrigin(agg);
        }
      

      Exception is:

      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.metadata.RelMdColumnOrigins.getColumnOrigins(RelMdColumnOrigins.java:77)
      	at GeneratedMetadataHandler_ColumnOrigin.getColumnOrigins_$(Unknown Source)
      	at GeneratedMetadataHandler_ColumnOrigin.getColumnOrigins(Unknown Source)
      	at org.apache.calcite.rel.metadata.RelMetadataQuery.getColumnOrigins(RelMetadataQuery.java:345)
      	at org.apache.calcite.rel.metadata.RelMetadataQuery.getTableOrigin(RelMetadataQuery.java:418)
      	at org.apache.calcite.test.RelMetadataTest.testEmptyAggregateNotCausesException(RelMetadataTest.java:2396)
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                kgyrtkirk Zoltan Haindrich
                Reporter:
                kgyrtkirk Zoltan Haindrich
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: