You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by jn...@apache.org on 2016/10/30 15:23:25 UTC

[5/5] drill git commit: DRILL-4884: Fix IOB exception in limit n query when n is beyond 65535.

DRILL-4884: Fix IOB exception in limit n query when n is beyond 65535.

close apache/drill#584


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/1e6fa00c
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/1e6fa00c
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/1e6fa00c

Branch: refs/heads/master
Commit: 1e6fa00cd4b0b1db41614749f6d12c03f0ca7990
Parents: 2081d76
Author: hongze.zhz <ho...@alibaba-inc.com>
Authored: Fri Sep 9 16:19:16 2016 +0800
Committer: Jinfeng Ni <jn...@apache.org>
Committed: Sat Oct 29 22:12:36 2016 -0700

----------------------------------------------------------------------
 .../physical/impl/limit/LimitRecordBatch.java   |   4 ++--
 .../java/org/apache/drill/TestBugFixes.java     |  21 +++++++++++++++++++
 .../limit_test_parquet/test0_0_0.parquet        | Bin 0 -> 428815 bytes
 3 files changed, 23 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/1e6fa00c/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/limit/LimitRecordBatch.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/limit/LimitRecordBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/limit/LimitRecordBatch.java
index 176ee17..08ffc0b 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/limit/LimitRecordBatch.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/limit/LimitRecordBatch.java
@@ -163,8 +163,8 @@ public class LimitRecordBatch extends AbstractSingleRecordBatch<Limit> {
     }
 
     int svIndex = 0;
-    for(char i = (char) offset; i < fetch; svIndex++, i++) {
-      outgoingSv.setIndex(svIndex, i);
+    for(int i = offset; i < fetch; svIndex++, i++) {
+      outgoingSv.setIndex(svIndex, (char) i);
     }
     outgoingSv.setRecordCount(svIndex);
   }

http://git-wip-us.apache.org/repos/asf/drill/blob/1e6fa00c/exec/java-exec/src/test/java/org/apache/drill/TestBugFixes.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestBugFixes.java b/exec/java-exec/src/test/java/org/apache/drill/TestBugFixes.java
index 5b736bc..03b1b61 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/TestBugFixes.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/TestBugFixes.java
@@ -17,12 +17,17 @@
  */
 package org.apache.drill;
 
+import com.google.common.collect.ImmutableList;
 import org.apache.drill.common.exceptions.UserException;
 import org.apache.drill.common.util.TestTools;
 import org.apache.drill.exec.planner.physical.PlannerSettings;
 import org.junit.Ignore;
 import org.junit.Test;
 
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
 public class TestBugFixes extends BaseTestQuery {
   private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestBugFixes.class);
   private static final String WORKING_PATH = TestTools.getWorkingPath();
@@ -200,4 +205,20 @@ public class TestBugFixes extends BaseTestQuery {
             .baselineValues("M", 554L, 11.9)
             .build().run();
   }
+
+  @Test
+  public void testDRILL4884() throws Exception {
+    int limit = 65536;
+    ImmutableList.Builder<Map<String, Object>> baselineBuilder = ImmutableList.builder();
+    for (int i = 0; i < limit; i++) {
+      baselineBuilder.add(Collections.<String, Object>singletonMap("`id`", String.valueOf(i + 1)));
+    }
+    List<Map<String, Object>> baseline = baselineBuilder.build();
+
+    testBuilder()
+            .sqlQuery(String.format("select id from dfs_test.`%s/bugs/DRILL-4884/limit_test_parquet/test0_0_0.parquet` group by id limit %s", TEST_RES_PATH, limit))
+            .unOrdered()
+            .baselineRecords(baseline)
+            .go();
+  }
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/1e6fa00c/exec/java-exec/src/test/resources/bugs/DRILL-4884/limit_test_parquet/test0_0_0.parquet
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/bugs/DRILL-4884/limit_test_parquet/test0_0_0.parquet b/exec/java-exec/src/test/resources/bugs/DRILL-4884/limit_test_parquet/test0_0_0.parquet
new file mode 100644
index 0000000..15b1c25
Binary files /dev/null and b/exec/java-exec/src/test/resources/bugs/DRILL-4884/limit_test_parquet/test0_0_0.parquet differ