[
https://issues.apache.org/jira/browse/CALCITE-888?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Julian Hyde updated CALCITE-888:
--------------------------------
Description:
Having parenthesis around window would produce wrong result. For example,
{code}
select empno, sum(empno) over (w), count(*) over w
from emp
window w as (partition by empno order by empno)
{code}
Notice that the second select item has parenthesis in the window clause. This
query would generate a wrong plan:
{code}
LogicalProject(EMPNO=[$0], $1=[$9], $2=[$10])
LogicalWindow(window#0=[window(partition {} order by [0] range between
UNBOUNDED PRECEDING and CURRENT ROW aggs [SUM($0)])],
window#1=[window(partition {0} order by [0] range between UNBOUNDED PRECEDING
and CURRENT ROW aggs [COUNT()])])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
{code}
where we have two windows in the LogicalWindow.
was:
For example,
{code}
select empno, sum(empno) over (w), count(*) over w
from emp
window w as (partition by empno order by empno)
{code}
Notice that the second select item has parenthesis in the window clause. This
query would generate a wrong plan:
{code}
LogicalProject(EMPNO=[$0], $1=[$9], $2=[$10])
LogicalWindow(window#0=[window(partition {} order by [0] range between
UNBOUNDED PRECEDING and CURRENT ROW aggs [SUM($0)])],
window#1=[window(partition {0} order by [0] range between UNBOUNDED PRECEDING
and CURRENT ROW aggs [COUNT()])])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
{code}
where we have two windows in the LogicalWindow.
> Overlay window loses PARTITION BY list
> --------------------------------------
>
> Key: CALCITE-888
> URL: https://issues.apache.org/jira/browse/CALCITE-888
> Project: Calcite
> Issue Type: Bug
> Reporter: Sean Hsuan-Yi Chu
> Assignee: Julian Hyde
>
> Having parenthesis around window would produce wrong result. For example,
> {code}
> select empno, sum(empno) over (w), count(*) over w
> from emp
> window w as (partition by empno order by empno)
> {code}
> Notice that the second select item has parenthesis in the window clause. This
> query would generate a wrong plan:
> {code}
> LogicalProject(EMPNO=[$0], $1=[$9], $2=[$10])
> LogicalWindow(window#0=[window(partition {} order by [0] range between
> UNBOUNDED PRECEDING and CURRENT ROW aggs [SUM($0)])],
> window#1=[window(partition {0} order by [0] range between UNBOUNDED PRECEDING
> and CURRENT ROW aggs [COUNT()])])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> {code}
> where we have two windows in the LogicalWindow.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)