xiedeyantu commented on code in PR #5040:
URL: https://github.com/apache/calcite/pull/5040#discussion_r3473343331


##########
core/src/test/resources/sql/sub-query.iq:
##########
@@ -2540,11 +2541,12 @@ EnumerableCalc(expr#0..5=[{inputs}], expr#6=[NOT($t3)], 
expr#7=[IS NOT NULL($t3)
     EnumerableSort(sort0=[$2], dir0=[ASC])
       EnumerableCalc(expr#0..7=[{inputs}], EMPNO=[$t0], SAL=[$t5], 
DEPTNO=[$t7])
         EnumerableTableScan(table=[[scott, EMP]])
-    EnumerableSort(sort0=[$1], dir0=[ASC])
-      EnumerableCalc(expr#0..1=[{inputs}], expr#2=[false], expr#3=[1], 
expr#4=[<=($t1, $t3)], cs=[$t2], DEPTNO=[$t0], rn=[$t1], $condition=[$t4])
-        EnumerableWindow(window#0=[window(partition {0} rows between UNBOUNDED 
PRECEDING and CURRENT ROW aggs [ROW_NUMBER()])], constants=[[false]])
-          EnumerableCalc(expr#0..2=[{inputs}], DEPTNO=[$t0])
-            EnumerableTableScan(table=[[scott, DEPT]])
+    EnumerableCalc(expr#0..2=[{inputs}], expr#3=[1], expr#4=[<=($t2, $t3)], 
proj#0..2=[{exprs}], $condition=[$t4])

Review Comment:
   The plan generated by the new correlation algorithm looks much better.
   ```
   !use scott
   !set outputformat mysql
   select sal from emp e
     where 123 NOT IN (
       select cast(null as int)
       from dept d where e.deptno=d.deptno);
   +-----+
   | SAL |
   +-----+
   +-----+
   (0 rows)
   
   !ok
   EnumerableCalc(expr#0..3=[{inputs}], expr#4=[NOT($t3)], SAL=[$t1], 
$condition=[$t4])
     EnumerableHashJoin(condition=[AND(IS NOT DISTINCT FROM($2, $4), =(123, 
$3))], joinType=[left_mark])
       EnumerableCalc(expr#0..7=[{inputs}], EMPNO=[$t0], SAL=[$t5], 
DEPTNO=[$t7])
         EnumerableTableScan(table=[[scott, EMP]])
       EnumerableCalc(expr#0..2=[{inputs}], expr#3=[null:INTEGER], $f0=[$t3], 
DEPTNO=[$t0])
         EnumerableTableScan(table=[[scott, DEPT]])
   !plan
   ```



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