drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject [2/2] drill git commit: DRILL-1932: Query fails if the first record batch does not contain any record
Date Wed, 21 Jan 2015 07:22:00 GMT
DRILL-1932: Query fails if the first record batch does not contain any record

+ Added test case which runs a query against an HBase table with first and last region empty.


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

Branch: refs/heads/master
Commit: 8d1e1affe86a5adca3bc17eeaf7520f0d379a393
Parents: 50c0949
Author: Aditya Kishore <adi@apache.org>
Authored: Thu Jan 1 02:57:49 2015 -0800
Committer: Aditya Kishore <adi@apache.org>
Committed: Tue Jan 20 23:02:03 2015 -0800

----------------------------------------------------------------------
 .../org/apache/drill/hbase/HBaseTestsSuite.java |  1 +
 .../apache/drill/hbase/TestHBaseQueries.java    | 63 ++++++++++++++++++++
 .../apache/drill/hbase/TestTableGenerator.java  |  2 +-
 .../drill/exec/physical/impl/ScanBatch.java     |  5 +-
 4 files changed, 69 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/8d1e1aff/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/HBaseTestsSuite.java
----------------------------------------------------------------------
diff --git a/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/HBaseTestsSuite.java
b/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/HBaseTestsSuite.java
index 888a9f5..96a887e 100644
--- a/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/HBaseTestsSuite.java
+++ b/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/HBaseTestsSuite.java
@@ -34,6 +34,7 @@ import org.junit.runners.Suite.SuiteClasses;
 
 @RunWith(Suite.class)
 @SuiteClasses({
+  TestHBaseQueries.class,
   TestHBaseRegexParser.class,
   HBaseRecordReaderTest.class,
   TestHBaseFilterPushDown.class,

http://git-wip-us.apache.org/repos/asf/drill/blob/8d1e1aff/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestHBaseQueries.java
----------------------------------------------------------------------
diff --git a/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestHBaseQueries.java
b/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestHBaseQueries.java
new file mode 100644
index 0000000..f842acc
--- /dev/null
+++ b/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestHBaseQueries.java
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.hbase;
+
+import java.util.Arrays;
+
+import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.client.HBaseAdmin;
+import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.client.Put;
+import org.junit.Test;
+
+public class TestHBaseQueries extends BaseHBaseTest {
+
+  @Test
+  public void testWithEmptyFirstAndLastRegion() throws Exception {
+    HBaseAdmin admin = HBaseTestsSuite.getAdmin();
+    String tableName = "drill_ut_empty_regions";
+    HTable table = null;
+
+    try {
+    HTableDescriptor desc = new HTableDescriptor(tableName);
+    desc.addFamily(new HColumnDescriptor("f"));
+    admin.createTable(desc, Arrays.copyOfRange(TestTableGenerator.SPLIT_KEYS, 0, 2));
+
+    table = new HTable(admin.getConfiguration(), tableName);
+    Put p = new Put("b".getBytes());
+    p.add("f".getBytes(), "c".getBytes(), "1".getBytes());
+    table.put(p);
+
+    setColumnWidths(new int[] {8, 15});
+    runHBaseSQLVerifyCount("SELECT *\n"
+        + "FROM\n"
+        + "  hbase.`" + tableName + "` tableName\n"
+        , 1);
+    } finally {
+      try {
+        if (table != null) {
+          table.close();
+        }
+        admin.disableTable(tableName);
+        admin.deleteTable(tableName);
+      } catch (Exception e) { } // ignore
+    }
+
+  }
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/8d1e1aff/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestTableGenerator.java
----------------------------------------------------------------------
diff --git a/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestTableGenerator.java
b/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestTableGenerator.java
index c244f9e..097947c 100644
--- a/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestTableGenerator.java
+++ b/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestTableGenerator.java
@@ -28,7 +28,7 @@ import org.apache.hadoop.hbase.client.Put;
 
 public class TestTableGenerator {
 
-  static final byte[][] SPLIT_KEYS = {
+  public static final byte[][] SPLIT_KEYS = {
     {'b'}, {'c'}, {'d'}, {'e'}, {'f'}, {'g'}, {'h'}, {'i'},
     {'j'}, {'k'}, {'l'}, {'m'}, {'n'}, {'o'}, {'p'}, {'q'},
     {'r'}, {'s'}, {'t'}, {'u'}, {'v'}, {'w'}, {'x'}, {'y'}, {'z'}

http://git-wip-us.apache.org/repos/asf/drill/blob/8d1e1aff/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/ScanBatch.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/ScanBatch.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/ScanBatch.java
index 29bf68e..d68a5b5 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/ScanBatch.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/ScanBatch.java
@@ -47,7 +47,6 @@ import org.apache.drill.exec.record.WritableBatch;
 import org.apache.drill.exec.record.selection.SelectionVector2;
 import org.apache.drill.exec.record.selection.SelectionVector4;
 import org.apache.drill.exec.store.RecordReader;
-import org.apache.drill.exec.util.CallBack;
 import org.apache.drill.exec.vector.AllocationHelper;
 import org.apache.drill.exec.vector.NullableVarCharVector;
 import org.apache.drill.exec.vector.SchemaChangeCallBack;
@@ -161,6 +160,10 @@ public class ScanBatch implements RecordBatch {
             currentReader.cleanup();
             releaseAssets();
             done = true;
+            if (mutator.isNewSchema()) {
+              container.buildSchema(SelectionVectorMode.NONE);
+              schema = container.getSchema();
+            }
             return IterOutcome.NONE;
           }
           oContext.getStats().startSetup();


Mime
View raw message