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

Zhen Chen edited comment on CALCITE-7373 at 1/15/26 3:20 PM:
-------------------------------------------------------------

Do we need to consider the pushdown in this scenario? That is, the case where 
the condition containing rand() includes a join key.
{code:java}
select * from (
  select dept.deptno from dept inner join
  emp on dept.deptno = emp.deptno) R
    where deptno <= rand() * 100; {code}


was (Author: jensen):
Do we need to consider the pushdown in this scenario? That is, the case where 
the condition containing rand() includes a join key.
select * from (
  select dept.deptno from dept inner join
  emp on dept.deptno = emp.deptno) R
   where deptno <= rand() * 100;

> FILTER_INTO_JOIN should not push Filter into a join when the Filter contains 
> non-deterministic function
> -------------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-7373
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7373
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: xiong duan
>            Assignee: xiong duan
>            Priority: Major
>              Labels: pull-request-available
>
> The test in RelOptRulesTest:
> {code:java}
>   <TestCase name="testPushFilterThroughSemiJoin5">
>     <Resource name="sql">
>       <![CDATA[select * from (
>   select * from dept where dept.deptno in (
>     select emp.deptno from emp))R
> where 0.9 <= RANDOM()]]>
>     </Resource>
>     <Resource name="planBefore">
>       <![CDATA[
> LogicalProject(DEPTNO=[$0], NAME=[$1])
>   LogicalFilter(condition=[<=(CAST(0.9:DECIMAL(2, 1)):DOUBLE NOT NULL, 
> RANDOM())])
>     LogicalJoin(condition=[=($0, $2)], joinType=[semi])
>       LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
>       LogicalProject(DEPTNO=[$7])
>         LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> ]]>
>     </Resource>
>     <Resource name="planAfter">
>       <![CDATA[
> LogicalProject(DEPTNO=[$0], NAME=[$1])
>   LogicalJoin(condition=[=($0, $2)], joinType=[semi])
>     LogicalFilter(condition=[<=(0.9E0, RANDOM())])
>       LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
>     LogicalProject(DEPTNO=[$7])
>       LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> ]]>
>     </Resource>
>   </TestCase> {code}
> The Filter constains RANDOM() should not be push down.
>  



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

Reply via email to