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 2019/07/22 09:42:06 UTC

[GitHub] [calcite] jinxing64 commented on a change in pull request #1153: [CALCITE-1338] JoinProjectTransposeRule makes wrong transformation when the right child of left outer join has a RexLiteral project expression

jinxing64 commented on a change in pull request #1153: [CALCITE-1338] JoinProjectTransposeRule makes wrong transformation when the right child of left outer join has a RexLiteral project expression
URL: https://github.com/apache/calcite/pull/1153#discussion_r305757381
 
 

 ##########
 File path: core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
 ##########
 @@ -510,6 +510,118 @@ private void basePushFilterPastAggWithGroupingSets(boolean unchanged)
     checkPlanning(tester, preProgram, new HepPlanner(program), sql);
   }
 
+  /** Test case for
+   * <a href="https://issues.apache.org/jira/browse/CALCITE-1338">[CALCITE-1338]
+   * Should not transpose since the right project of left join has literal</a>. */
+  @Test public void testJoinProjectTranspose2() {
+    final HepProgram program =
+        HepProgram.builder()
+            .addRuleInstance(JoinProjectTransposeRule.RIGHT_PROJECT_INCLUDE_OUTER)
+            .build();
+    final String sql = "select *\n"
+        + "from dept a \n"
+        + "left join (select name, 1 from dept) as b\n"
+        + "on a.name = b.name";
+    checkPlanUnchanged(new HepPlanner(program), sql);
+  }
+
+  /** Test case for
+   * <a href="https://issues.apache.org/jira/browse/CALCITE-1338">[CALCITE-1338]
+   * Should not transpose since the left project of right join has literal</a>. */
+  @Test public void testJoinProjectTranspose3() {
+    final HepProgram program =
+        HepProgram.builder()
+            .addRuleInstance(JoinProjectTransposeRule.LEFT_PROJECT_INCLUDE_OUTER)
+            .build();
+    final String sql = "select *\n"
+        + "from (select name, 1 from dept) as a\n"
+        + "right join dept b\n"
+        + "on a.name = b.name";
+    checkPlanUnchanged(new HepPlanner(program), sql);
+  }
+
+  /** Test case for
+   * <a href="https://issues.apache.org/jira/browse/CALCITE-1338">[CALCITE-1338]
+   * Should not transpose since the right project of left join has not-strong
+   * expression {@code y is not null}</a>. */
+  @Test public void testJoinProjectTranspose4() {
+    final HepProgram program =
+        HepProgram.builder()
+            .addRuleInstance(JoinProjectTransposeRule.RIGHT_PROJECT_INCLUDE_OUTER)
+            .build();
+    final String sql = "select *\n"
+        + "from dept a\n"
+        + "left join (select x name, y is not null from\n"
+        + "(values (2, cast(null as integer)), (2, 1)) as t(x, y)) b\n"
+        + "on a.name = b.name";
+    checkPlanUnchanged(new HepPlanner(program), sql);
 
 Review comment:
   Hi @chunweilei , I'm learning this PR ~
   In the right project of this left-join, the field of `name` is of Integer type. Do you really mean this?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services