[ 
https://issues.apache.org/jira/browse/CALCITE-5717?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17724756#comment-17724756
 ] 

Julian Hyde commented on CALCITE-5717:
--------------------------------------

These rewrites have tricky semantics. First, "select 1 from emps group by ()" 
returns different results from "select distinct 1 from emps", for reasons that 
are very subtle. Second, we don't want to be introducing RelNodes that have 
zero fields.

I have done some work on this in CALCITE-4334 and I think we should have the 
discussion there. LITERAL_AGG function allows us to create an Aggregate that 
projects a constant, and therefore avoid the problem of zero-width RelNodes.

> Prune Project's input if project has no InputRef and the input has 1 row
> ------------------------------------------------------------------------
>
>                 Key: CALCITE-5717
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5717
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>            Reporter: Benchao Li
>            Assignee: Benchao Li
>            Priority: Major
>              Labels: pull-request-available
>
> The idea is to improve SQL
> {code:sql}
> select 1 from emps group by ()
> {code}
> In this case, we can safely prune the Aggregate.
> This idea is brought up in the discussion of CALCITE-5506
> We can add this improvement to ProjectAggregateMergeRule



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to