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

Julian Hyde edited comment on CALCITE-4154 at 8/5/20, 8:16 PM:
---------------------------------------------------------------

[~amaliujia], Optimizations other than projection are possible. For example, 
{{COALESCE(SUM\(x), 0)}} can be converted to {{SUM0\(x)}}. (To see why {{SUM0}} 
is superior, see CALCITE-3957.)


was (Author: julianhyde):
[~amaliujia], Optimizations other than projection are possible. For example, 
{{COALESCE(SUM(x), 0)}} can be converted to {{SUM0(x)}}. (To see why {{SUM0}} 
is superior, see CALCITE-3957.)

> Add a rule to merge a Project onto an Aggregate
> -----------------------------------------------
>
>                 Key: CALCITE-4154
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4154
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Julian Hyde
>            Assignee: Julian Hyde
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Add a rule to merge a {{Project}} onto an {{Aggregate}}. In practice, it 
> means that aggregate functions that are not used in the Project are removed 
> from the Aggregate.
> For example,
> {code:java}
> SELECT deptno, sum_sal
> FROM (
>   SELECT deptno, job, SUM(sal) AS sum_sal, MIN(ename) AS min_ename
>   FROM emp
>   GROUP BY deptno, job)
> {code}
> becomes
> {code:java}
> SELECT deptno, sum_sal
> FROM (
>   SELECT deptno, job, SUM(sal) AS sum_sal
>   FROM emp
>   GROUP BY deptno, job)
> {code}
> Note that {{min_ename}} is removed from the {{Aggregate}} (because it is not 
> used by the {{Project}}). {{job}} is not used, but it remains because it is a 
> {{GROUP BY}} key.



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

Reply via email to