You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2021/12/03 12:14:03 UTC

[GitHub] [calcite] korlov42 commented on a change in pull request #2623: CALCITE-4913 Correlated variables in a select list are not deduplicated

korlov42 commented on a change in pull request #2623:
URL: https://github.com/apache/calcite/pull/2623#discussion_r761884509



##########
File path: core/src/main/java/org/apache/calcite/rel/logical/LogicalProject.java
##########
@@ -35,52 +37,63 @@
 import org.apache.calcite.util.Util;
 
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
 
 import org.checkerframework.checker.nullness.qual.Nullable;
 
 import java.util.List;
+import java.util.Objects;
+import java.util.Set;
 
 /**
  * Sub-class of {@link org.apache.calcite.rel.core.Project} not
  * targeted at any particular engine or calling convention.
  */
 public final class LogicalProject extends Project {
+  private final ImmutableSet<CorrelationId> variablesSet;

Review comment:
       It does make sense for project with correlated scalar queries. For example, the query like `SELECT t0.v, (SELECT t0.v + t1.v FROM test_tbl t1) AS j FROM test_tbl t0` has a logical plan:
   ```
   LogicalProject(V=[$2], J=[$SCALAR_QUERY({
   LogicalProject(T0.V + T1.V=[+($cor0.V, $2)])
     IgniteLogicalTableScan(table=[[PUBLIC, TEST_TBL]])
   })])
     IgniteLogicalTableScan(table=[[PUBLIC, TEST_TBL]])
   ```
   In order to evaluate this plan you need either implement filter that set correlation variable, or convert it to LogicalCorrelate (what is actually done by `SubQueryRemoveRule` ).
   
   With that said, it seems to me LogicalFilter has to expose the variables they set, but not every physical implementation would do so.




-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org