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


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/rel/IgniteLimit.java:
##########
@@ -176,12 +176,19 @@ public RelOptCost computeSelfCost(RelOptPlanner planner, 
RelMetadataQuery mq) {
     /** {@inheritDoc} */
     @Override
     public double estimateRowCount(RelMetadataQuery mq) {
-        double inputRowCount = mq.getRowCount(getInput());
+        return estimateRowCount(mq.getRowCount(getInput()), offset, fetch);
+    }
 
+    /** Returns the estimated row count based on provided input and offset and 
fetch attributes. */
+    public static double estimateRowCount(
+            double inputRowCount,
+            @Nullable RexNode offset,
+            @Nullable RexNode fetch
+    ) {
         double lim = fetch != null ? doubleFromRex(fetch, inputRowCount * 
FETCH_IS_PARAM_FACTOR) : inputRowCount;
         double off = offset != null ? doubleFromRex(offset, inputRowCount * 
OFFSET_IS_PARAM_FACTOR) : 0;
 
-        return Math.max(0, Math.min(lim, inputRowCount - off));
+        return Math.max(1, Math.min(lim, inputRowCount - off));

Review Comment:
   Didn't catch, why do the method can't return zero?



##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/rel/IgniteLimit.java:
##########
@@ -176,12 +176,19 @@ public RelOptCost computeSelfCost(RelOptPlanner planner, 
RelMetadataQuery mq) {
     /** {@inheritDoc} */
     @Override
     public double estimateRowCount(RelMetadataQuery mq) {
-        double inputRowCount = mq.getRowCount(getInput());
+        return estimateRowCount(mq.getRowCount(getInput()), offset, fetch);
+    }
 
+    /** Returns the estimated row count based on provided input and offset and 
fetch attributes. */
+    public static double estimateRowCount(
+            double inputRowCount,
+            @Nullable RexNode offset,
+            @Nullable RexNode fetch
+    ) {
         double lim = fetch != null ? doubleFromRex(fetch, inputRowCount * 
FETCH_IS_PARAM_FACTOR) : inputRowCount;
         double off = offset != null ? doubleFromRex(offset, inputRowCount * 
OFFSET_IS_PARAM_FACTOR) : 0;
 
-        return Math.max(0, Math.min(lim, inputRowCount - off));
+        return Math.max(1, Math.min(lim, inputRowCount - off));

Review Comment:
   Didn't catch, why the method can't return zero?



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