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

Jiajun Xie commented on CALCITE-6632:
-------------------------------------

[~asolimando] , ok.

I added the digest and here is my 
PR:https://github.com/apache/calcite/pull/4007/files

> Wrong optimization because window missing constants in digest
> -------------------------------------------------------------
>
>                 Key: CALCITE-6632
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6632
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>         Environment: !image-2024-10-17-10-41-11-032.png|width=482,height=203!
>            Reporter: Jiajun Xie
>            Assignee: Jiajun Xie
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: image-2024-10-17-10-41-11-032.png
>
>
> Here is a simple case:
> {code:java}
> select sum(100) over (partition by deptno order by sal) as s -- window1
> from emp
> union all
> select sum(1000) over(partition by deptno order by sal) as s -- window2
> from emp {code}
> window1 is different from window2.
> But window digest missing constants, the window2 will be replaced by window1 
> after optimized.
> {code:java}
> LogicalUnion(all=[true])
>   LogicalProject($0=[$2])
>     LogicalWindow(window#0=[window(partition {1} order by [0] aggs 
> [SUM($2)])]) -- window1 digest
>       LogicalProject(SAL=[$5], DEPTNO=[$7])
>         LogicalTableScan(table=[[CATALOG, SALES, EMP]])
>   LogicalProject($0=[$2])
>     LogicalWindow(window#0=[window(partition {1} order by [0] aggs 
> [SUM($2)])]) -- window1 digest
>       LogicalProject(SAL=[$5], DEPTNO=[$7])
>         LogicalTableScan(table=[[CATALOG, SALES, EMP]]) {code}



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

Reply via email to