iwanttobepowerful commented on code in PR #4654:
URL: https://github.com/apache/calcite/pull/4654#discussion_r2572713434
##########
core/src/test/resources/sql/sub-query.iq:
##########
@@ -5443,4 +5443,42 @@ ORDER BY deptno;
!ok
+# [CALCITE-7303] Subqueries cannot be decorrelated if filter condition have
multi CorrelationId
Review Comment:
when I add test case
```sql
with bonus1(ENAME, JOB, SAL, COMM) AS (VALUES
('ALLEN', 'SALESMAN', 1600.00, 300.00),
('WARD', 'SALESMAN', 1250.00, 500.00))
SELECT deptno
FROM emp e
WHERE EXISTS
(SELECT *
FROM dept d
WHERE EXISTS
(SELECT *
FROM bonus1 b
WHERE b.ename = e.ename
AND d.deptno = e.deptno));
+--------+
| DEPTNO |
+--------+
| 30 |
+--------+
(1 row)
```
this is wrong! should return 2 row.
```sql
!use scott
with bonus1(ENAME, JOB, SAL, COMM) AS (VALUES
('ALLEN', 'SALESMAN', 1600.00, 300.00),
('WARD', 'SALESMAN', 1250.00, 500.00))
SELECT * FROM bonus1
INNER JOIN emp
ON bonus1.ename = emp.ename
INNER JOIN dept
ON emp.deptno = dept.deptno;
ENAME, JOB, SAL, COMM, EMPNO, ENAME0, JOB0, MGR, HIREDATE, SAL0, COMM0,
DEPTNO, DEPTNO0, DNAME, LOC
ALLEN, SALESMAN, 1600.00, 300.00, 7499, ALLEN, SALESMAN, 7698, 1981-02-20,
1600.00, 300.00, 30, 30, SALES, CHICAGO
!ok
```
calcite return wrong result too!
right result is:
```
ename | job | sal | comm | empno | ename | job | mgr |
hiredate | sal | comm | deptno | dname | deptno | loc
-------+----------+---------+--------+-------+-------+----------+------+------------+---------+--------+--------+-------+--------+---------
WARD | SALESMAN | 1250.00 | 500.00 | 7521 | WARD | SALESMAN | 7698 |
1981-02-22 | 1250.00 | 500.00 | 30 | SALES | 30 | CHICAGO
ALLEN | SALESMAN | 1600.00 | 300.00 | 7499 | ALLEN | SALESMAN | 7698 |
1981-02-20 | 1600.00 | 300.00 | 30 | SALES | 30 | CHICAGO
(2 rows)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]