You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by "Xurenhe (Jira)" <ji...@apache.org> on 2021/08/17 12:31:00 UTC

[jira] [Created] (CALCITE-4743) Convert rel to sql fail, when meeting aggregate of no-group and no-aggcall.

Xurenhe created CALCITE-4743:
--------------------------------

             Summary: Convert rel to sql fail, when meeting aggregate of no-group and no-aggcall.
                 Key: CALCITE-4743
                 URL: https://issues.apache.org/jira/browse/CALCITE-4743
             Project: Calcite
          Issue Type: Bug
          Components: core
            Reporter: Xurenhe
         Attachments: image-2021-08-17-20-27-45-801.png

Hi, all.
Here, Aggregate of of no-group and no-agg-call coverting to sql is fail.
For example:
{code:java}
  @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);
  }
{code}
This case will return sql: 
{code:sql}
SELECT 'hello' AS "constant_field"
FROM "scott"."EMP"
GROUP BY ()
{code}
--------------------------------------
Should we use a switch of dialect to control this conversion, which is code of `org.apache.calcite.rel.rel2sql.RelToSqlConverter#buildAggregate`?

 !image-2021-08-17-20-27-45-801.png|thumbnail! 





--
This message was sent by Atlassian Jira
(v8.3.4#803005)