iwanttobepowerful commented on code in PR #4998:
URL: https://github.com/apache/calcite/pull/4998#discussion_r3400289981


##########
core/src/test/resources/sql/sub-query.iq:
##########
@@ -8168,6 +8168,41 @@ SELECT deptno FROM dept WHERE 1000.00 >
 
 !ok
 
+# [CALCITE-7587] RelDecorrelator fails on correlated scalar subquery with 
ROW_NUMBER window function
+# due to RexOver nullability mismatch
+# Correlated scalar sub-query in the SELECT list that contains a window 
function.
+# Decorrelation must add the correlation key to the window partition and 
preserve nullability
+# of the OVER expression after pulling it above the left correlate.
+SELECT e.ename,
+  (SELECT ROW_NUMBER() OVER (PARTITION BY e.deptno ORDER BY e.empno, d.deptno)
+   FROM dept d
+   WHERE e.deptno = d.deptno) AS rn
+FROM emp e
+ORDER BY e.empno;
+!if (use_old_decorr) {

Review Comment:
   let https://github.com/apache/calcite/pull/5014 merge firstly. And then new 
decorrelator can return right result.



-- 
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]

Reply via email to