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

Zhen Chen commented on CALCITE-6990:
------------------------------------

I have a question: is this allowed, or is it a bug? A FILTER clause containing 
rand() can be pushed down to the child of a JOIN.
{code:java}
!set hep-rules "
+CoreRules.FILTER_INTO_JOIN,
+CoreRules.JOIN_CONDITION_PUSH"
select emp.ename, dept.dname from emp join dept on emp.deptno = dept.deptno 
where sal + 10 * rand() > 20;

EnumerableCalc(expr#0..5=[{inputs}], ENAME=[$t1], DNAME=[$t5])
  EnumerableHashJoin(condition=[=($3, $4)], joinType=[inner])
    EnumerableCalc(expr#0..7=[{inputs}], expr#8=[10], expr#9=[RAND()], 
expr#10=[*($t8, $t9)], expr#11=[+($t5, $t10)], expr#12=[20.0E0:DOUBLE], 
expr#13=[>($t11, $t12)], proj#0..1=[{exprs}], SAL=[$t5], DEPTNO=[$t7], 
$condition=[$t13])
      EnumerableTableScan(table=[[scott, EMP]])
    EnumerableCalc(expr#0..2=[{inputs}], proj#0..1=[{exprs}])
      EnumerableTableScan(table=[[scott, DEPT]])
!plan {code}

> Optimization passes should be checked for handling DynamicParameter
> -------------------------------------------------------------------
>
>                 Key: CALCITE-6990
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6990
>             Project: Calcite
>          Issue Type: Task
>          Components: core
>    Affects Versions: 1.39.0
>            Reporter: Mihai Budiu
>            Priority: Minor
>
> Several PRs have fixed optimization passes which are wrong when queries can 
> contain dynamic parameters. Perhaps all of the passes should be audited with 
> this case in mind.
> See [CALCITE-6647] and [CALCITE-6983]



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

Reply via email to