iwanttobepowerful commented on code in PR #4997:
URL: https://github.com/apache/calcite/pull/4997#discussion_r3370821584
##########
core/src/test/resources/sql/sub-query.iq:
##########
@@ -8168,6 +8168,578 @@ SELECT deptno FROM dept WHERE 1000.00 >
!ok
+# [CALCITE-7584] RelDecorrelator produces incorrect results for correlated
LATERAL sub-queries with window functions
+# Correlated LATERAL sub-query with a window expression.
+# The equality predicate between the inner and outer query must remain applied
+# after decorrelation.
+SELECT e.ename, d.deptno, d.m
+FROM emp e
+JOIN LATERAL (
+ SELECT d.deptno,
+ MAX(d.deptno + e.empno) OVER (PARTITION BY e.deptno) AS m
+ FROM dept d
+ WHERE e.deptno = d.deptno
+) d ON TRUE
+ORDER BY e.empno;
+!if (use_old_decorr) {
Review Comment:
```sql
SELECT e.ename, d.deptno, d.rn
FROM emp e
JOIN LATERAL (
SELECT d.deptno,
ROW_NUMBER() OVER (PARTITION BY e.deptno ORDER BY e.empno, d.deptno) AS
rn
FROM dept d
WHERE e.deptno = d.deptno
) d ON TRUE
ORDER BY e.empno;
```
and
```sql
SELECT 1
FROM calcite_7584_t1 t1
WHERE t1b = (SELECT MAX(tmp.s) FROM (
SELECT SUM(t2c) OVER (PARTITION BY t2c ORDER BY t1.t1d + t2d)
AS s
FROM calcite_7584_t2 t2) AS tmp);
```
failed in TOPDOWN_GENERAL_DECORRELATION
--
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]