You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "clintropolis (via GitHub)" <gi...@apache.org> on 2025/09/05 21:44:33 UTC

Re: [PR] MSQ: Push down limits in ScanQueryFrameProcessor. (druid)

clintropolis commented on code in PR #18441:
URL: https://github.com/apache/druid/pull/18441#discussion_r2323311108


##########
multi-stage-query/src/main/java/org/apache/druid/msq/querykit/scan/ScanQueryFrameProcessor.java:
##########
@@ -497,4 +550,19 @@ private ColumnSelectorFactory wrapColumnSelectorFactoryIfNeeded(final ColumnSele
     }
     return baseColumnSelectorFactory;
   }
+
+  /**
+   * Returns the {@link ScanQuery#getScanRowsOffset()} plus {@link ScanQuery#getScanRowsLimit()}, or
+   * {@link Long#MAX_VALUE} if that addition would overflow.
+   */
+  private long getQueryOffsetPlusLimit()
+  {
+    final long sum = query.getScanRowsOffset() + query.getScanRowsLimit();
+    if (sum < 0) {
+      // Overflow
+      return Long.MAX_VALUE;

Review Comment:
   should this be a failure?



##########
multi-stage-query/src/main/java/org/apache/druid/msq/querykit/scan/ScanQueryFrameProcessor.java:
##########
@@ -479,6 +522,16 @@ private long setNextCursor(
     this.cursorCloser = cursorCloser;
     this.segment = segment;
     this.cursorOffset.reset();
+    this.cursorRowsRead = 0;
+
+    if (query.isLimited()
+        && ordering.size() >= query.getOrderBys().size()
+        && query.getOrderBys().equals(ordering.subList(0, query.getOrderBys().size()))) {

Review Comment:
   in the future it might be nice to have a 'same but reversed direction' check so that we could make reverse cursors match too



-- 
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: commits-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org