NobiGo commented on code in PR #2774:
URL: https://github.com/apache/calcite/pull/2774#discussion_r855799246


##########
core/src/main/java/org/apache/calcite/rel/metadata/RelMdRowCount.java:
##########
@@ -147,45 +146,27 @@ public Double getRowCount(Calc rel, RelMetadataQuery mq) {
     if (rowCount == null) {
       return null;
     }
-    if (rel.offset instanceof RexDynamicParam) {
-      return rowCount;
-    }
-    final int offset = rel.offset == null ? 0 : 
RexLiteral.intValue(rel.offset);
+
+    final int offset = rel.offset instanceof RexLiteral ? 
RexLiteral.intValue(rel.offset) : 0;
     rowCount = Math.max(rowCount - offset, 0D);
 
-    if (rel.fetch != null) {
-      if (rel.fetch instanceof RexDynamicParam) {
-        return rowCount;
-      }
-      final int limit = RexLiteral.intValue(rel.fetch);
-      if (limit < rowCount) {
-        return (double) limit;
-      }
-    }
-    return rowCount;
+    final double limit =
+        rel.fetch instanceof RexLiteral ? RexLiteral.intValue(rel.fetch) : 
rowCount;
+    return limit < rowCount ? limit : rowCount;
   }
 
   public @Nullable Double getRowCount(EnumerableLimit rel, RelMetadataQuery 
mq) {
     Double rowCount = mq.getRowCount(rel.getInput());
     if (rowCount == null) {
       return null;
     }
-    if (rel.offset instanceof RexDynamicParam) {
-      return rowCount;
-    }
-    final int offset = rel.offset == null ? 0 : 
RexLiteral.intValue(rel.offset);
+
+    final int offset = rel.offset instanceof RexLiteral ? 
RexLiteral.intValue(rel.offset) : 0;
     rowCount = Math.max(rowCount - offset, 0D);

Review Comment:
   The limit number is the max row count that the SQL can return.



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