zzwqqq commented on code in PR #5385:
URL: https://github.com/apache/calcite/pull/5385#discussion_r4438743278


##########
core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java:
##########
@@ -159,6 +170,21 @@ public class RelDecorrelator implements ReflectiveVisitor {
   private static final Logger SQL2REL_LOGGER =
       CalciteTrace.getSqlToRelTracer();
 
+  private static final RexShuttle DETERMINISM_CHECKER = new RexShuttle() {
+    @Override public RexNode visitCall(RexCall call) {
+      checkDeterministicExpression(call);
+      return call;
+    }
+
+    @Override public RexNode visitOver(RexOver over) {
+      return visitCall(over);
+    }
+
+    @Override public RexNode visitSubQuery(RexSubQuery subQuery) {
+      throw Util.FoundOne.NULL;

Review Comment:
   Thanks @mihaibudiu , I've added a comment. FoundOne is caught by  
RelDecorrelator#isDeterministic, which returns false so the Correlate is 
retained.
   
   Even a deterministic sub-query can lose its outer binding during 
decorrelation, as in 
[CALCITE-7913](https://issues.apache.org/jira/browse/CALCITE-7913), so I took a 
conservative approach here. Alternatively, would you prefer to fix CALCITE-7913 
first?



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