[
https://issues.apache.org/jira/browse/CALCITE-7017?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
suibianwanwan reassigned CALCITE-7017:
--------------------------------------
Assignee: suibianwanwan
> Incorrect subquery rewriting in join conditions when join type is outer join
> ----------------------------------------------------------------------------
>
> Key: CALCITE-7017
> URL: https://issues.apache.org/jira/browse/CALCITE-7017
> Project: Calcite
> Issue Type: Bug
> Reporter: suibianwanwan
> Assignee: suibianwanwan
> Priority: Major
>
> Test in sub-query.iq
> {code:java}
> SELECT e1.*
> FROM emp e1
> LEFT JOIN dept d
> ON e1.deptno = d.deptno
> AND e1.empno IN (
> SELECT e3.empno
> FROM emp e3
> WHERE e1.comm > e3.comm
> )
> ORDER BY e1.empno, e1.deptno;
> +-------+-------+-----+-----+----------+-----+------+--------+
> | EMPNO | ENAME | JOB | MGR | HIREDATE | SAL | COMM | DEPTNO |
> +-------+-------+-----+-----+----------+-----+------+--------+
> +-------+-------+-----+-----+----------+-----+------+--------+
> (0 rows)
> EnumerableSort(sort0=[$0], sort1=[$7], dir0=[ASC], dir1=[ASC])
> EnumerableCalc(expr#0..9=[{inputs}], EMPNO=[$t2], ENAME=[$t3], JOB=[$t4],
> MGR=[$t5], HIREDATE=[$t6], SAL=[$t7], COMM=[$t8], DEPTNO=[$t9])
> EnumerableHashJoin(condition=[AND(=($1, $8), =($0, $2))],
> joinType=[inner])
> EnumerableCalc(expr#0..2=[{inputs}], EMPNO=[$t0], COMM0=[$t2])
> EnumerableNestedLoopJoin(condition=[>($2, $1)], joinType=[inner])
> EnumerableCalc(expr#0..7=[{inputs}], EMPNO=[$t0], COMM=[$t6])
> EnumerableTableScan(table=[[scott, EMP]])
> EnumerableAggregate(group=[{6}])
> EnumerableTableScan(table=[[scott, EMP]])
> EnumerableTableScan(table=[[scott, EMP]])
> {code}
> Expected result:
> {code:java}
> +-------+--------+-----------+------+------------+---------+---------+--------+
> | EMPNO | ENAME | JOB | MGR | HIREDATE | SAL | COMM | DEPTNO
> |
> +-------+--------+-----------+------+------------+---------+---------+--------+
> | 7369 | SMITH | CLERK | 7902 | 1980-12-17 | 800.00 | | 20
> |
> | 7499 | ALLEN | SALESMAN | 7698 | 1981-02-20 | 1600.00 | 300.00 | 30
> |
> | 7521 | WARD | SALESMAN | 7698 | 1981-02-22 | 1250.00 | 500.00 | 30
> |
> | 7566 | JONES | MANAGER | 7839 | 1981-02-04 | 2975.00 | | 20
> |
> | 7654 | MARTIN | SALESMAN | 7698 | 1981-09-28 | 1250.00 | 1400.00 | 30
> |
> | 7698 | BLAKE | MANAGER | 7839 | 1981-01-05 | 2850.00 | | 30
> |
> | 7782 | CLARK | MANAGER | 7839 | 1981-06-09 | 2450.00 | | 10
> |
> | 7788 | SCOTT | ANALYST | 7566 | 1987-04-19 | 3000.00 | | 20
> |
> | 7839 | KING | PRESIDENT | | 1981-11-17 | 5000.00 | | 10
> |
> | 7844 | TURNER | SALESMAN | 7698 | 1981-09-08 | 1500.00 | 0.00 | 30
> |
> | 7876 | ADAMS | CLERK | 7788 | 1987-05-23 | 1100.00 | | 20
> |
> | 7900 | JAMES | CLERK | 7698 | 1981-12-03 | 950.00 | | 30
> |
> | 7902 | FORD | ANALYST | 7566 | 1981-12-03 | 3000.00 | | 20
> |
> | 7934 | MILLER | CLERK | 7782 | 1982-01-23 | 1300.00 | | 10
> |
> +-------+--------+-----------+------+------------+---------+---------+--------+
> (14 rows)
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)