[
https://issues.apache.org/jira/browse/CALCITE-4743?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17406482#comment-17406482
]
Julian Hyde commented on CALCITE-4743:
--------------------------------------
Also related to CALCITE-4597. Until we resolve that issue, a RelNode with zero
output fields is illegal.
> 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
> Priority: Major
> 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)