You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "DongShengHe (Jira)" <ji...@apache.org> on 2026/07/28 15:00:00 UTC
[jira] [Created] (CALCITE-7679) RelToSqlConverter generates GROUP BY literals for dialects that do not support them when the constant is hidden by nested Projects
DongShengHe created CALCITE-7679:
------------------------------------
Summary: RelToSqlConverter generates GROUP BY literals for dialects that do not support them when the constant is hidden by nested Projects
Key: CALCITE-7679
URL: https://issues.apache.org/jira/browse/CALCITE-7679
Project: Calcite
Issue Type: Bug
Reporter: DongShengHe
h3. Description
{{RelToSqlConverter}} may generate a literal in the {{GROUP BY}} clause for dialects that do not support them when the grouping expression is hidden behind multiple {{Project}} nodes.
This is related to CALCITE-4702. Its fix uses {{AggregateProjectConstantToDummyJoinRule}} for dialects that do not support grouping by literals. However, the rule only examines the {{Project}} directly below the {{{}Aggregate{}}}.
For example, consider the following relational plan:
{code:java}
LogicalAggregate(group=[{0}])
LogicalProject(ID=[$0])
LogicalProject(ID=[null:NULL])
LogicalTableScan(table=[[hr, emps]]) {code}
{{{}{}}}{{{}{}}}
The direct project expression is {{{}$0{}}}, so {{AggregateProjectConstantToDummyJoinRule}} does not recognize it as a literal.
As a result, the PostgreSQL dialect generates:
{code:java}
SELECT NULL AS "ID"
FROM "hr"."emps"
GROUP BY NULL {code}
{{}}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)