Repository: incubator-drill Updated Branches: refs/heads/master cd6dd9c6f -> 17a4d9214
DRILL-1393: Set record count before clearing SV2 in RecordBatchData Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/38c5d4e4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/38c5d4e4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/38c5d4e4 Branch: refs/heads/master Commit: 38c5d4e4bb693fe65118f84463dce9246d7096fe Parents: cd6dd9c Author: Mehant Baid <meha...@gmail.com> Authored: Thu Oct 2 21:07:16 2014 -0700 Committer: Mehant Baid <meha...@gmail.com> Committed: Wed Oct 15 18:24:02 2014 -0700 ---------------------------------------------------------------------- .../drill/exec/physical/impl/sort/RecordBatchData.java | 3 ++- .../src/test/java/org/apache/drill/TestExampleQueries.java | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/38c5d4e4/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/sort/RecordBatchData.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/sort/RecordBatchData.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/sort/RecordBatchData.java index 419dc85..fbd472e 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/sort/RecordBatchData.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/sort/RecordBatchData.java @@ -42,6 +42,8 @@ public class RecordBatchData { public RecordBatchData(VectorAccessible batch) { List<ValueVector> vectors = Lists.newArrayList(); + recordCount = batch.getRecordCount(); + if (batch instanceof RecordBatch && batch.getSchema().getSelectionVectorMode() == SelectionVectorMode.TWO_BYTE) { this.sv2 = ((RecordBatch)batch).getSelectionVector2().clone(); } else { @@ -58,7 +60,6 @@ public class RecordBatchData { } container.addCollection(vectors); - recordCount = batch.getRecordCount(); container.setRecordCount(recordCount); container.buildSchema(batch.getSchema().getSelectionVectorMode()); } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/38c5d4e4/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java b/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java index 8efd6bd..f2bcc1e 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java +++ b/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java @@ -20,6 +20,7 @@ package org.apache.drill; import org.apache.drill.common.util.FileUtils; import org.apache.drill.exec.rpc.RpcException; import org.junit.Test; +import static org.junit.Assert.assertEquals; public class TestExampleQueries extends BaseTestQuery{ static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestExampleQueries.class); @@ -486,4 +487,12 @@ public class TestExampleQueries extends BaseTestQuery{ test("select t1.full_name from cp.`employee.json` t1, cp.`department.json` t2 where cast(t1.department_id as double) = t2.department_id and cast(t1.position_id as bigint) = t2.department_id"); test("select t1.full_name from cp.`employee.json` t1, cp.`department.json` t2 where t1.department_id = t2.department_id and t1.position_id = t2.department_id"); } + + @Test + public void testTopNWithSV2() throws Exception { + int actualRecordCount = testSql("select N_NATIONKEY from cp.`tpch/nation.parquet` where N_NATIONKEY < 10 order by N_NATIONKEY limit 5"); + int expectedRecordCount = 5; + assertEquals(String.format("Received unexepcted number of rows in output: expected=%d, received=%s", + expectedRecordCount, actualRecordCount), expectedRecordCount, actualRecordCount); + } }