Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.38.0
Description
Here is an an example plan before and after this rule:
LogicalProject(EXPR$0=[CASE(>($3, 0), $4, null:INTEGER)], salary=[$0], enroll_date=[$1]), id = 630
LogicalWindow(window#0=[window(order by [1] range between $2 PRECEDING and $2 FOLLOWING aggs [COUNT($0), $SUM0($0)])]), id = 628
LogicalProject(salary=[$2], enroll_date=[$3], $2=[*(365, 86400000:INTERVAL DAY)]), id = 626
LogicalTableScan(table=[[schema, empsalary]]), id = 592
after:
LogicalProject(EXPR$0=[CASE(>($2, 0), $3, null:INTEGER)], salary=[$0], enroll_date=[$1]), id = 645
LogicalWindow(window#0=[window(order by [1] range between $2 PRECEDING and $2 FOLLOWING aggs [COUNT($0), $SUM0($0)])]), id = 643
LogicalProject(salary=[$0], enroll_date=[$1]), id = 639
LogicalProject(salary=[$2], enroll_date=[$3], $2=[*(365, 86400000:INTERVAL DAY)]), id = 633
LogicalTableScan(table=[[schema, empsalary]]), id = 592
The problem is the representation of the window bound, which refers to field $2. After this optimization this field no longer exists in the project that is an input to the Window.
I suspect that the problem is in the code ProjectWindowTransposeRule that maintains the beReferred bitset; it never adds the window bounds to this set.
Attachments
Issue Links
- is duplicated by
-
CALCITE-6750 ProjectWindowTransposeRule does not consider references in bounds
-
- Resolved
-
- links to