Yu Xu created CALCITE-7493:
------------------------------
Summary: Support constant-result aggregates (e.g., COUNT, STDDEV)
over GROUP BY keys
Key: CALCITE-7493
URL: https://issues.apache.org/jira/browse/CALCITE-7493
Project: Calcite
Issue Type: Bug
Components: core
Affects Versions: 1.41.0
Reporter: Yu Xu
Sql like:
{code:java}
select sal, count(sal) as cnt, stddev(sal) as sd,
stddev_pop(sal) as sdp, var_pop(sal) as vp, var_samp(sal) as vs
from emp group by sal, deptno {code}
It should be able to be optimized to:
||agg funcions||Better simplified results||
|{{COUNT(sal)}}|{{{}1{}}}(或 {{{}COUNT(){}}})|
|{{STDDEV(sal)}}|{{0}}|
|{{STDDEV_POP(sal)}}|{{0}}|
|{{VAR_POP(sal)}}|{{0}}|
|{{VAR_SAMP(sal)}}|{{NULL}}|
and current plan:
{code:java}
LogicalProject(SAL=[$0], CNT=[$2], SD=[$3], SDP=[$4], VP=[$5], VS=[$6])
LogicalAggregate(group=[{0, 1}], CNT=[COUNT()], SD=[STDDEV($0)],
SDP=[STDDEV_POP($0)], VP=[VAR_POP($0)], VS=[VAR_SAMP($0)])
LogicalProject(SAL=[$5], DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]]) {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)