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/02/09 02:30:31 UTC

[GitHub] [calcite] xy2953396112 commented on a change in pull request #2702: [CALCITE-4800] Define a new rule of SortToSortUnifyRule in SubstitutionVisitor to support sort's match

xy2953396112 commented on a change in pull request #2702:
URL: https://github.com/apache/calcite/pull/2702#discussion_r802219578



##########
File path: core/src/test/java/org/apache/calcite/test/MaterializedViewSubstitutionVisitorTest.java
##########
@@ -1259,6 +1259,259 @@ protected final MaterializedViewFixture sql(String materialize,
     sql(mv, query).ok();
   }
 
+  /**
+   * It need be matched, info of offset and fetch.
+   * eg: mv[null, null], query[null, 3].
+   */
+  @Test void testSortToSort1() {
+    final String mv = ""
+        + "select \"name\", \"deptno\"\n"
+        + "from \"emps\"\n"
+        + "order by \"deptno\"";
+    final String query = ""
+        + "select \"name\", \"deptno\"\n"
+        + "from \"emps\"\n"
+        + "order by \"deptno\"\n"
+        + "fetch next 3 rows only";
+    sql(mv, query)
+        .checkingThatResultContains(""
+            + "LogicalSort(fetch=[3])\n"
+            + "  EnumerableTableScan(table=[[hr, MV0]])")
+        .ok();
+  }
+
+  /**
+   * It need be matched, info of offset and fetch.
+   * eg: mv[null, null], query[2, 3].
+   */
+  @Test void testSortToSort2() {
+    final String mv = ""
+        + "select \"name\", \"deptno\"\n"
+        + "from \"emps\"\n"
+        + "order by \"deptno\"";
+    final String query = ""
+        + "select \"name\", \"deptno\"\n"
+        + "from \"emps\"\n"
+        + "order by \"deptno\"\n"
+        + "offset 2 rows\n"
+        + "fetch next 3 rows only";
+    sql(mv, query)
+        .checkingThatResultContains(""
+            + "LogicalSort(offset=[2], fetch=[3])\n"
+            + "  EnumerableTableScan(table=[[hr, MV0]])")
+        .ok();
+  }
+
+  /**
+   * It need be matched, info of offset and fetch.
+   * eg: mv[2, null], query[3, null]
+   */
+  @Test void testSortToSort3() {
+    final String mv = ""
+        + "select \"name\", \"deptno\"\n"
+        + "from \"emps\"\n"
+        + "order by \"deptno\"\n"
+        + "offset 2 rows";
+    final String query = ""

Review comment:
       how about `order by name`?




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