xiedeyantu commented on code in PR #4707:
URL: https://github.com/apache/calcite/pull/4707#discussion_r2648737600


##########
core/src/main/java/org/apache/calcite/rel/metadata/RelMdMaxRowCount.java:
##########
@@ -115,11 +117,10 @@ public Double getMaxRowCount(Sort rel, RelMetadataQuery 
mq) {
       rowCount = Double.POSITIVE_INFINITY;
     }
 
-    final long offset = rel.offset instanceof RexLiteral ? 
RexLiteral.longValue(rel.offset) : 0;
+    final double offset = literalNumericValue(rel.offset, 0D);

Review Comment:
   Thank you for pointing that out. The currently used 
   "long" could indeed have the same issue. The current logic is all about 
metadata calculation (like row counts), and it’s actually quite easy for the 
number of rows to exceed the precision limit, especially in scenarios like the 
optimizer relying on row counts for cost estimation. If this logic doesn’t 
affect the actual computation of OFFSET/LIMIT in operators, I suppose it’s 
acceptable, but there is certainly a hidden risk.
   
   Currently, the interfaces in these three classes all use 
   "Double" as the return type. Changing them to 
   "BigDecimal" would require significant modifications. Is it worth doing?



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