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

xiong duan edited comment on CALCITE-6469 at 7/13/24 3:20 PM:
--------------------------------------------------------------

CALCITE-5183 support SQL is:
{code:java}
SELECT emp.deptno, emp.sal
FROM dept
LEFT JOIN emp ON (SELECT AVG(emp.sal) > 0 FROM emp) {code}
That's different in the ON condition.


was (Author: nobigo):
CALCITE-5183 support SQL is:
SELECT emp.deptno, emp.sal
FROM dept
         LEFT JOIN emp ON (SELECT AVG(emp.sal) > 0 FROM emp) 
That's different in the ON condition.

> Join on condition generates wrong plan when the condition is IN sub-query
> -------------------------------------------------------------------------
>
>                 Key: CALCITE-6469
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6469
>             Project: Calcite
>          Issue Type: Bug
>    Affects Versions: 1.37.0
>            Reporter: xiong duan
>            Assignee: xiong duan
>            Priority: Major
>             Fix For: 1.38.0
>
>
> Now Calcite will throw an exception when we execute the SQL:
> {code:java}
> select *  from scott.bonus b left join scott.emp e on e.deptno in (select 
> deptno from scott.dept b){code}
> I will try to rewrite this SQL become:
> {code:java}
> SELECT *
> FROM "SCOTT"."BONUS"
> LEFT JOIN ("SCOTT"."EMP" INNER JOIN (SELECT "DEPTNO"
> FROM "SCOTT"."DEPT"
> GROUP BY "DEPTNO") AS "t" ON "EMP"."DEPTNO" = "t"."DEPTNO") ON TRUE{code}
> The SQL :
> {code:java}
> select *  from scott.emp e left join scott.bonus b on e.deptno in (select 
> deptno from scott.dept b) {code}
> I will try to rewrite this SQL become:
> {code:java}
> SELECT *
> FROM "SCOTT"."EMP"
> LEFT JOIN ("SCOTT"."BONUS" CROSS JOIN (SELECT "DEPTNO"
> FROM "SCOTT"."DEPT"
> GROUP BY "DEPTNO") AS "t") ON "EMP"."DEPTNO" = "t"."DEPTNO" {code}



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

Reply via email to