Yu Xu created CALCITE-6890:
------------------------------

             Summary: AggregateReduceFunctionsRule support sum function to be 
reduced
                 Key: CALCITE-6890
                 URL: https://issues.apache.org/jira/browse/CALCITE-6890
             Project: Calcite
          Issue Type: Improvement
          Components: core
    Affects Versions: 1.38.0
            Reporter: Yu Xu
            Assignee: Yu Xu
             Fix For: 1.40.0


Currently AggregateReduceFunctionsRule not support sum function can be reduced, 
should support for the function. 

*for example:*
select sal, max(sal) as sal_max, min(sal) as sal_min,
avg(sal) sal_avg, any_value(sal) as sal_val, first_value(sal) as sal_first,
sum(sal) sal_sum,
last_value(sal) as sal_last
from emp group by sal, deptno
 
*logic plan is :*
LogicalProject(SAL=[$0], SAL_MAX=[$0], SAL_MIN=[$0], SAL_AVG=[$0], 
SAL_VAL=[$0], SAL_FIRST=[$0], SAL_SUM=[$2], SAL_LAST=[$0])
  *LogicalAggregate(group=[\{0, 1}], SAL_SUM=[$SUM0($0)])*
    LogicalProject(SAL=[$5], DEPTNO=[$7])
      LogicalTableScan(table=[[CATALOG, SALES, EMP]])
 
*should be:*
LogicalProject(SAL=[$0], SAL_MAX=[$0], SAL_MIN=[$0], SAL_AVG=[$0], 
SAL_VAL=[$0], SAL_FIRST=[$0], SAL_SUM=[$0], SAL_LAST=[$0])
  LogicalAggregate(group=[\{0, 1}])
    LogicalProject(SAL=[$5], DEPTNO=[$7])
      LogicalTableScan(table=[[CATALOG, SALES, EMP]])



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

Reply via email to