[ 
https://issues.apache.org/jira/browse/CALCITE-6632?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Mihai Budiu resolved CALCITE-6632.
----------------------------------
    Fix Version/s: 1.39.0
       Resolution: Fixed

Fixed in 
https://github.com/apache/calcite/commit/72963da2e76e7961bec5aa19aa9bdfdd99c33a05
Thank you for the contribution, [~jiajunbernoulli]

> 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
>             Fix For: 1.39.0
>
>         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