Vladsz83 commented on code in PR #9987:
URL: https://github.com/apache/ignite/pull/9987#discussion_r861780921


##########
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/LimitExecutionTest.java:
##########
@@ -48,6 +48,70 @@ public void testLimit() throws Exception {
         checkLimit(2000, 3000);
     }
 
+    /** Tests Sort node can as well limit its output when fetch param is set. 
*/
+    @Test
+    public void testSort() throws Exception {
+        int bufSize = U.field(AbstractNode.class, "IN_BUFFER_SIZE");
+
+        checkLimitSort(0, 1);
+        checkLimitSort(1, 0);
+        checkLimitSort(1, 1);
+        checkLimitSort(0, bufSize);
+        checkLimitSort(bufSize, 0);
+        checkLimitSort(bufSize, bufSize);
+        checkLimitSort(bufSize - 1, 1);
+        checkLimitSort(2000, 0);
+        checkLimitSort(0, 3000);
+        checkLimitSort(2000, 3000);
+    }
+
+    /**
+     * @param offset Rows offset.
+     * @param fetch Fetch rows count (zero means unlimited).
+     */
+    private void checkLimitSort(int offset, int fetch) {
+        ExecutionContext<Object[]> ctx = executionContext(F.first(nodes()), 
UUID.randomUUID(), 0);
+        IgniteTypeFactory tf = ctx.getTypeFactory();
+        RelDataType rowType = TypeUtils.createRowType(tf, int.class);
+
+        RootNode<Object[]> rootNode = new RootNode<>(ctx, rowType);
+
+        SortNode<Object[]> sortNode = new SortNode<>(ctx, rowType, 
F::compareArrays, () -> offset,
+            fetch == 0 ? null : () -> fetch);
+
+        SourceNode srcNode = new SourceNode(ctx, rowType, fetch > 0 ? fetch * 
10 + offset :

Review Comment:
   Fixed. SourceNode can now shuffle the data.



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

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to