[
https://issues.apache.org/jira/browse/CALCITE-6011?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
LakeShen reassigned CALCITE-6011:
---------------------------------
Assignee: LakeShen
> Add the RelRule that pushes the Filter past a Window
> ----------------------------------------------------
>
> Key: CALCITE-6011
> URL: https://issues.apache.org/jira/browse/CALCITE-6011
> Project: Calcite
> Issue Type: Improvement
> Reporter: LakeShen
> Assignee: LakeShen
> Priority: Major
>
> The Filter condition could be pushed past the Window when condition used
> columns is window partition columns.
> For example:
> {code:java}
> SELECT
> *
> FROM
> (
> SELECT
> custkey,
> orderkey,
> rank() OVER (
> PARTITION BY custkey
> ORDER BY
> orderdate ASC
> )
> FROM
> orders
> )
> WHERE
> custkey = 0
> AND orderkey > 0 {code}
> The plan tree:
> {code:java}
> LogicalProject(custkey=[0], orderkey=[$1], EXPR$2=[$2])
> LogicalFilter(condition=[AND(=($0, 0), >($1, 0))])
> LogicalProject(custkey=[$1], orderkey=[$0], EXPR$2=[$3])
> LogicalWindow(window#0=[window(partition {1} order by [2] aggs
> [RANK()])])
> LogicalProject(ORDERKEY=[$0], CUSTKEY=[$1], ORDERDATE=[$4])
> LogicalTableScan(table=[[tpch, ORDERS]]) {code}
> Because the window partition columns is custkey,so the condition `custkey = 0
> ` could be pushed down the LogicalWindow.
> After that,the plan is :
> {code:java}
>
> LogicalProject(custkey=[0], orderkey=[$1], EXPR$2=[$2])
> LogicalFilter(condition=[>($1, 0)])
> LogicalProject(custkey=[$1], orderkey=[$0], EXPR$2=[$3])
> LogicalWindow(window#0=[window(partition {1} order by [2] aggs
> [RANK()])])
> LogicalFilter(condition=[=($1, 0)])
> LogicalProject(ORDERKEY=[$0], CUSTKEY=[$1], ORDERDATE=[$4])
> LogicalTableScan(table=[[tpch, ORDERS]])
> {code}
>
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)