Repository: drill Updated Branches: refs/heads/master d855906b9 -> fe3da5ce9
DRILL-4165 Fix a bug in counting records in outgoing batch. Project: http://git-wip-us.apache.org/repos/asf/drill/repo Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/0ced1986 Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/0ced1986 Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/0ced1986 Branch: refs/heads/master Commit: 0ced1986f281f830c695ede94138a461431ed8f4 Parents: d855906 Author: Amit Hadke <[email protected]> Authored: Mon Dec 7 14:13:55 2015 -0800 Committer: Amit Hadke <[email protected]> Committed: Mon Dec 7 14:13:55 2015 -0800 ---------------------------------------------------------------------- .../drill/exec/physical/impl/join/JoinStatus.java | 4 ++-- .../drill/exec/physical/impl/join/JoinTemplate.java | 8 ++++++-- .../exec/physical/impl/join/TestMergeJoinAdvanced.java | 12 ++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/drill/blob/0ced1986/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/JoinStatus.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/JoinStatus.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/JoinStatus.java index f7154f8..e968236 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/JoinStatus.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/JoinStatus.java @@ -99,7 +99,7 @@ public final class JoinStatus { } public final boolean isOutgoingBatchFull() { - return outputPosition == OUTPUT_BATCH_SIZE; + return outputPosition >= OUTPUT_BATCH_SIZE; } public final void incOutputPos() { @@ -160,4 +160,4 @@ public final class JoinStatus { return getLeftStatus() == outcome || getRightStatus() == outcome; } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/drill/blob/0ced1986/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/JoinTemplate.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/JoinTemplate.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/JoinTemplate.java index ed900db..40c47b3 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/JoinTemplate.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/JoinTemplate.java @@ -83,6 +83,12 @@ public abstract class JoinTemplate implements JoinWorker { doCopyRight(status.right.getCurrentPosition(), status.getOutPosition()); status.incOutputPos(); } + if (status.isOutgoingBatchFull()) { + // Leave iterators at their current positions and markers. + // Don't mark on all subsequent doJoin iterations. + status.disableMarking(); + return true; + } // Move to next position in right iterator. status.right.next(); while (!status.right.finished()) { @@ -91,8 +97,6 @@ public abstract class JoinTemplate implements JoinWorker { doCopyRight(status.right.getCurrentPosition(), status.getOutPosition()); status.incOutputPos(); if (status.isOutgoingBatchFull()) { - // Leave iterators at their current positions and markers. - // Don't mark on all subsequent doJoin iterations. status.disableMarking(); return true; } http://git-wip-us.apache.org/repos/asf/drill/blob/0ced1986/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestMergeJoinAdvanced.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestMergeJoinAdvanced.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestMergeJoinAdvanced.java index 87058f2..05776d3 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestMergeJoinAdvanced.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestMergeJoinAdvanced.java @@ -202,4 +202,16 @@ public class TestMergeJoinAdvanced extends BaseTestQuery { final long left = r.nextInt(10001) + 1l; testMultipleBatchJoin(left, right, "right", left * right + 3l); } + + @Test + public void testDrill4165() throws Exception { + final String query1 = "select count(*) cnt from cp.`tpch/lineitem.parquet` l1, cp.`tpch/lineitem.parquet` l2 where l1.l_partkey = l2.l_partkey and l1.l_suppkey < 30 and l2.l_suppkey < 30"; + testBuilder() + .sqlQuery(query1) + .optionSettingQueriesForTestQuery("alter session set `planner.enable_hashjoin` = false") + .unOrdered() + .baselineColumns("cnt") + .baselineValues(202452l) + .go(); + } }
