[ 
https://issues.apache.org/jira/browse/CALCITE-2720?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16706426#comment-16706426
 ] 

Julian Hyde edited comment on CALCITE-2720 at 12/4/18 12:44 AM:
----------------------------------------------------------------

Fixed in 
[5ebf458f|http://git-wip-us.apache.org/repos/asf/calcite/commit/5ebf458f]; 
thanks for the PR, [~kgyrtkirk]!


was (Author: julianhyde):
Fixed in 
[7f8556e6|http://git-wip-us.apache.org/repos/asf/calcite/commit/7f8556e6]; 
thanks for the PR, [~kgyrtkirk]!

> Presence of an empty aggregation should not lead to Exceptions
> --------------------------------------------------------------
>
>                 Key: CALCITE-2720
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2720
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Zoltan Haindrich
>            Assignee: Zoltan Haindrich
>            Priority: Major
>             Fix For: 1.18.0
>
>
> 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.
> {code}
>   @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);
>   }
> {code}
> Exception is:
> {code}
> 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)
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to