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

Convert rel to sql fail, when meeting aggregate of no-group and no-aggcall.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • core
    • None

    Description

      Hi, all.
      Here, Aggregate of of no-group and no-agg-call coverting to sql is fail.
      For example:

        @Test void testAggregateWithNoGroupAndNoAggCall() {
          final RelBuilder builder = relBuilder();
          final RelNode relRoot = builder.scan("EMP")
              .aggregate(builder.groupKey())
              .project(ImmutableList.of(builder.literal("hello")), ImmutableList.of("constant_field"))
              .build();
      
          String expected = "SELECT 'hello' AS \"constant_field\"\n"
              + "FROM \"scott\".\"EMP\"";
          relFn(b -> relRoot).ok(expected);
        }
      

      This case will return sql:

      SELECT 'hello' AS "constant_field"
      FROM "scott"."EMP"
      GROUP BY ()
      

      --------------------------------------
      Should we use a switch of dialect to control this conversion, which is code of `org.apache.calcite.rel.rel2sql.RelToSqlConverter#buildAggregate`?

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              wojustme Xurenhe
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: