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

LakeShen commented on CALCITE-6031:
-----------------------------------

This PR is Ready, the PR link is : [https://github.com/apache/calcite/pull/3453]

If others have time, please help me to review it, thank you very much:)

> Add the RelRule that pushes the Filter past a Sample
> ----------------------------------------------------
>
>                 Key: CALCITE-6031
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6031
>             Project: Calcite
>          Issue Type: New Feature
>          Components: core
>            Reporter: LakeShen
>            Assignee: LakeShen
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.36.0
>
>
> The Filter could be pushed past the Sample.
> For example:
> {code:java}
> select deptno from "scott".dept tablesample system(50) where  deptno > 
> 10{code}
> The plan tree is :
> {code:java}
>  LogicalProject(o_orderkey=[$0])
>   LogicalFilter(condition=[>($0, 0)])
>     Sample(mode=[system], rate=[0.5], repeatableSeed=[-])
>       LogicalTableScan(table=[[tpch, ORDERS]]) {code}
> Could be rewrite to :
> {code:java}
>   LogicalProject(o_orderkey=[$0])
>     Sample(mode=[system], rate=[0.5], repeatableSeed=[-])
>       LogicalFilter(condition=[>($0, 0)])      
>         LogicalTableScan(table=[[tpch, ORDERS]]) {code}
> The same logic could see Presto/Trino: 
> [PredicatePushDown.Rewriter#visitSample|https://github.com/prestodb/presto/blob/597272cea3eb39c35ed40ffc100f830dd4ab055c/presto-main/src/main/java/com/facebook/presto/sql/planner/optimizations/PredicatePushDown.java#L1670C9-L1674C10]



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

Reply via email to