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

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.16.0
    • Component/s: core
    • Labels:
      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

          Activity

            People

            • Assignee:
              jcamachorodriguez Jesus Camacho Rodriguez
              Reporter:
              jcamachorodriguez Jesus Camacho Rodriguez
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: