AMashenkov commented on code in PR #5479:
URL: https://github.com/apache/ignite-3/pull/5479#discussion_r2026551392


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/rel/LimitNode.java:
##########
@@ -89,19 +93,30 @@ public void push(RowT row) throws Exception {
         if (waiting == NOT_WAITING) {
             return;
         }
+
         ++rowsProcessed;
 
         --waiting;
 
         if (rowsProcessed > offset) {
-            if (fetchNode == null || rowsProcessed <= fetch + offset) {
+            if (fetchUndefined || rowsProcessed <= fetch + offset) {
+                // this two rows can`t be swapped, cause if all requested rows 
have been pushed it will trigger further request call.
+                --requested;
                 downstream().push(row);
             }
         }
 
-        if (fetch > 0 && rowsProcessed == fetch + offset && waiting > 0) {
+        // There several cases are possible:
+        //  1) requested = 512, limit = 1, offset = not defined: need to pass 
1 row and call end()
+        //  2) requested = 512, limit = 512, offset = not defined: just need 
to pass all rows without end() call
+        //  3) requested = 512, limit = 512, offset = 1: need to request 
initially 512 and further 1 row
+        if (fetch > 0 && rowsProcessed == fetch + offset && requested > 0) {

Review Comment:
   The first to comparison int the condition means the same as `fetchNone()`



-- 
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: notifications-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to