amaliujia commented on a change in pull request #2005:
URL: https://github.com/apache/calcite/pull/2005#discussion_r436881001



##########
File path: core/src/test/java/org/apache/calcite/test/TopDownOptTest.java
##########
@@ -132,6 +134,72 @@
         .check();
   }
 
+  // Order by left field(s): push down sort to left input.
+  @Test void testCorrelateInnerJoinDeriveLeft() {
+    final String sql = "select * from emp e\n"
+        + "join dept d on e.deptno=d.deptno\n"
+        + "order by e.ename";
+    Query.create(sql)
+        .addRule(JoinToCorrelateRule.INSTANCE)
+        .removeRule(EnumerableRules.ENUMERABLE_JOIN_RULE)
+        .removeRule(EnumerableRules.ENUMERABLE_MERGE_JOIN_RULE)
+        .removeRule(EnumerableRules.ENUMERABLE_SORT_RULE)
+        .check();
+  }
+
+  // Order by contains right field: sort cannot be pushed down.
+  @Test void testCorrelateInnerJoinNoDerive() {
+    final String sql = "select * from emp e\n"
+        + "join dept d on e.deptno=d.deptno\n"
+        + "order by e.ename, d.name";

Review comment:
       Thanks for adding such test cases!




----------------------------------------------------------------
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:
[email protected]


Reply via email to