[ 
https://issues.apache.org/jira/browse/CALCITE-3145?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Steven Talbot updated CALCITE-3145:
-----------------------------------
    Description: 
Can repro with a simple modification (adding more group fields than there are 
aggregate fields) of the test added in 
[https://github.com/apache/calcite/commit/e01ba5ab6e7c57348f9f7be2babf00ae007204b5]
{noformat}
/** Tests that {@link RelBuilder#aggregate} eliminates duplicate aggregate
 * calls and creates a {@code Project} to compensate. */
@Test public void testAggregateEliminatesDuplicateCalls2() {
  final RelBuilder builder = RelBuilder.create(config().build());
  RelNode root =
          builder.scan("EMP")
                  .aggregate(builder.groupKey(builder.field(0), 
builder.field(1), builder.field(2), builder.field(3), builder.field(4)),
                          builder.sum(builder.field(1)).as("S1"),
                          builder.count().as("C"),
                          builder.sum(builder.field(2)).as("S2"),
                          builder.sum(builder.field(1)).as("S1b"))
                  .build();
  final String expected = ""
          + "LogicalProject(S1=[$0], C=[$1], S2=[$2], S1b=[$0])\n"
          + "  LogicalAggregate(group=[{}], S1=[SUM($1)], C=[COUNT()], 
S2=[SUM($2)])\n"
          + "    LogicalTableScan(table=[[scott, EMP]])\n";
  assertThat(root, hasTree(expected));
}{noformat}
Note that the test isn't quite right, as the final expectation would need to be 
modified, but it reproduces the exception, which in this case is 
`java.lang.IndexOutOfBoundsException: Index: 4, Size: 4`

 

  was:
Can repro with a simple modification (adding more group fields than there are 
aggregate fields) of the test added in 
[https://github.com/apache/calcite/commit/e01ba5ab6e7c57348f9f7be2babf00ae007204b5]
{noformat}
/** Tests that {@link RelBuilder#aggregate} eliminates duplicate aggregate
* calls and creates a {@code Project} to compensate. */
@Test public void testAggregateEliminatesDuplicateCalls2() {
final RelBuilder builder = RelBuilder.create(config().build());
RelNode root =
builder.scan("EMP")
.aggregate(builder.groupKey(builder.field(0), builder.field(1), 
builder.field(2), builder.field(3), builder.field(4)),
builder.sum(builder.field(1)).as("S1"),
builder.count().as("C"),
builder.sum(builder.field(2)).as("S2"),
builder.sum(builder.field(1)).as("S1b"))
.build();
final String expected = ""
+ "LogicalProject(S1=[$0], C=[$1], S2=[$2], S1b=[$0])\n"
+ " LogicalAggregate(group=[{}], S1=[SUM($1)], C=[COUNT()], S2=[SUM($2)])\n"
+ " LogicalTableScan(table=[[scott, EMP]])\n";
assertThat(root, hasTree(expected));
}{noformat}
Note that the test isn't quite right, as the final expectation would need to be 
modified, but it reproduces the exception, which in this case is 
`java.lang.IndexOutOfBoundsException: Index: 4, Size: 4`

 


> Aggregate duplicate detection bug with group fields
> ---------------------------------------------------
>
>                 Key: CALCITE-3145
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3145
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Steven Talbot
>            Priority: Major
>
> Can repro with a simple modification (adding more group fields than there are 
> aggregate fields) of the test added in 
> [https://github.com/apache/calcite/commit/e01ba5ab6e7c57348f9f7be2babf00ae007204b5]
> {noformat}
> /** Tests that {@link RelBuilder#aggregate} eliminates duplicate aggregate
>  * calls and creates a {@code Project} to compensate. */
> @Test public void testAggregateEliminatesDuplicateCalls2() {
>   final RelBuilder builder = RelBuilder.create(config().build());
>   RelNode root =
>           builder.scan("EMP")
>                   .aggregate(builder.groupKey(builder.field(0), 
> builder.field(1), builder.field(2), builder.field(3), builder.field(4)),
>                           builder.sum(builder.field(1)).as("S1"),
>                           builder.count().as("C"),
>                           builder.sum(builder.field(2)).as("S2"),
>                           builder.sum(builder.field(1)).as("S1b"))
>                   .build();
>   final String expected = ""
>           + "LogicalProject(S1=[$0], C=[$1], S2=[$2], S1b=[$0])\n"
>           + "  LogicalAggregate(group=[{}], S1=[SUM($1)], C=[COUNT()], 
> S2=[SUM($2)])\n"
>           + "    LogicalTableScan(table=[[scott, EMP]])\n";
>   assertThat(root, hasTree(expected));
> }{noformat}
> Note that the test isn't quite right, as the final expectation would need to 
> be modified, but it reproduces the exception, which in this case is 
> `java.lang.IndexOutOfBoundsException: Index: 4, Size: 4`
>  



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

Reply via email to