silundong commented on code in PR #4840:
URL: https://github.com/apache/calcite/pull/4840#discussion_r3038489938


##########
core/src/main/java/org/apache/calcite/plan/RelOptUtil.java:
##########
@@ -4752,6 +4759,17 @@ public ImmutableBitSet build() {
       }
       return super.visitCall(call);
     }
+
+    @Override public Void visitSubQuery(RexSubQuery subQuery) {

Review Comment:
   The following may be an edge test case:
   the query
   ```
   select e1.empno 
   from emp e1, 
   lateral(
     select d.deptno 
     from emp e2 inner join dept d 
     on exists(
       select e3.empno from emp e3 where e3.empno = e2.empno and e3.empno = 
e1.empno
     )
   )
   ```
   initial plan
   ```
   LogicalProject(EMPNO=[$0])
     LogicalCorrelate(correlation=[$cor1], joinType=[inner], 
requiredColumns=[{0}])
       LogicalTableScan(table=[[CATALOG, SALES, EMP]])
       LogicalProject(DEPTNO=[$9])
         LogicalJoin(condition=[EXISTS({
   LogicalFilter(condition=[AND(=($0, $cor0.EMPNO), =($0, $cor1.EMPNO))])
     LogicalTableScan(table=[[CATALOG, SALES, EMP]])
   })], joinType=[inner], variablesSet=[[$cor0]])
           LogicalTableScan(table=[[CATALOG, SALES, EMP]])
           LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
   ```
   `RelOptUtil.getVariablesUsed` will return `$cor0` and `$cor1` for EXISTS 
subquery.



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