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 2022/09/30 09:38:46 UTC

[GitHub] [calcite] libenchao commented on a diff in pull request #2813: [CALCITE-5127] Error when executing query with subquery in select lis…

libenchao commented on code in PR #2813:
URL: https://github.com/apache/calcite/pull/2813#discussion_r984403160


##########
core/src/main/java/org/apache/calcite/rel/core/Project.java:
##########
@@ -137,20 +163,27 @@ protected Project(RelInput input) {
    * @param input Input
    * @param projects Project expressions
    * @param rowType Output row type
+   * @param variableSet The variable set.
    * @return New {@code Project} if any parameter differs from the value of this
    *   {@code Project}, or just {@code this} if all the parameters are
    *   the same
    *
    * @see #copy(RelTraitSet, List)
    */
   public abstract Project copy(RelTraitSet traitSet, RelNode input,
-      List<RexNode> projects, RelDataType rowType);
+      List<RexNode> projects, RelDataType rowType, Set<CorrelationId> variableSet);
+
+  @Deprecated // to be removed before 2.0
+  public Project copy(RelTraitSet traitSet, RelNode input,
+      List<RexNode> projects, RelDataType rowType) {
+    return copy(traitSet, input, projects, rowType, ImmutableSet.of());
+  }

Review Comment:
   The new copy method is used, such as following places: `FilterProjectTransposeRule`, `ProjectJoinRemoveRule`, `ProjectWindowTransposeRule`, `RelBuilder`. 
   And I still keep the old copy method to make it a compatible change. (We already changed `ProjectFactory`, hence I think it's ok to also add a new version copy method to allow downstream projects to adapt to the new `Project` with variables)



##########
core/src/test/java/org/apache/calcite/plan/RelWriterTest.java:
##########
@@ -998,6 +999,21 @@ void testCorrelateQuery(SqlExplainFormat format) {
         .assertThatPlan(isLinux(expected));
   }
 
+  @Test void testProjectionWithCorrelationVaribles() {
+    final Function<RelBuilder, RelNode> relFn = b -> b.scan("EMP")
+        .project(
+            ImmutableList.of(b.field("ENAME")),
+            ImmutableList.of("ename"),
+            true,
+            ImmutableSet.of(b.getCluster().createCorrel()))
+        .build();
+
+    final String expected = "LogicalProject(variablesSet=[[$cor0]], ename=[$1])\n"
+        + "  LogicalTableScan(table=[[scott, EMP]])\n";

Review Comment:
   Logged CALCITE-5304



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