From 35692680fc7aba21c498a92307ef082a581cb23a Mon Sep 17 00:00:00 2001 From: Justin Borromeo Date: Mon, 25 Mar 2019 16:15:49 -0700 Subject: [PATCH] Fix bug messing up count of rows --- .../query/scan/ScanQueryRunnerFactory.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/processing/src/main/java/org/apache/druid/query/scan/ScanQueryRunnerFactory.java b/processing/src/main/java/org/apache/druid/query/scan/ScanQueryRunnerFactory.java index 034a0d2e36f..7078b9f915a 100644 --- a/processing/src/main/java/org/apache/druid/query/scan/ScanQueryRunnerFactory.java +++ b/processing/src/main/java/org/apache/druid/query/scan/ScanQueryRunnerFactory.java @@ -268,20 +268,21 @@ public class ScanQueryRunnerFactory implements QueryRunnerFactory limit) { q.poll(); } - } - yielder = yielder.next(null); - // Finish scanning the interval containing the limit row - if (numRowsScanned > limit && finalInterval == null) { - long timestampOfLimitRow = next.getFirstEventTimestamp(scanQuery.getResultFormat()); - for (SegmentDescriptor descriptor : descriptorsOrdered) { - if (descriptor.getInterval().contains(timestampOfLimitRow)) { - finalInterval = descriptor.getInterval(); + + // Finish scanning the interval containing the limit row + if (numRowsScanned > limit && finalInterval == null) { + long timestampOfLimitRow = srv.getFirstEventTimestamp(scanQuery.getResultFormat()); + for (SegmentDescriptor descriptor : descriptorsOrdered) { + if (descriptor.getInterval().contains(timestampOfLimitRow)) { + finalInterval = descriptor.getInterval(); + } + } + if (finalInterval == null) { + throw new ISE("WTH??? Row came from an unscanned interval?"); } } - if (finalInterval == null) { - throw new ISE("WTH??? Row came from an unscanned interval?"); - } } + yielder = yielder.next(null); doneScanning = yielder.isDone() || (finalInterval != null && !finalInterval.contains(next.getFirstEventTimestamp(scanQuery.getResultFormat())));