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

RelBuilder wrongly skips creating an Aggregate that prunes columns, if input is unique

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.16.0
    • core
    • None

    Description

      Issue can be reproduced with following test:

        @Test public void testAggregate3() {
          final RelBuilder builder = RelBuilder.create(config().build());
          RelNode root =
              builder.scan("EMP")
                  .aggregate(
                      builder.groupKey(builder.field(1)),
                      builder.aggregateCall(SqlStdOperatorTable.COUNT, false, false,
                          null, "C"))
                  .aggregate(
                      builder.groupKey(builder.field(0)))
                  .build();
          assertThat(str(root),
              is(""
                  + "LogicalProject(ENAME=[$0])\n"
                  + "  LogicalAggregate(group=[{1}], C=[COUNT()])\n"
                  + "    LogicalTableScan(table=[[scott, EMP]])\n"));
        }
      

      Without fix, builder will generate following plan, which contains an unnecessary field (in Hive, this results in an assertion error in RelFieldTrimmer):

      LogicalAggregate(group=[{1}], C=[COUNT()])
          LogicalTableScan(table=[[scott, EMP]])
      

      Attachments

        Issue Links

          Activity

            People

              jcamacho Jesús Camacho Rodríguez
              jcamacho Jesús Camacho Rodríguez
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: