aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/storage-hbase/src/test/java/org/apache/drill/hbase/HBaseTestsSuite.java1
-rw-r--r--contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestHBaseQueries.java63
-rw-r--r--contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestTableGenerator.java2
-rw-r--r--exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/ScanBatch.java5
4 files changed, 69 insertions, 2 deletions
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 888a9f5e7..96a887e8b 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,
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 000000000..f842acc98
--- /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
+ }
+
+ }
+}
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 c244f9eb0..097947cab 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'}
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 29bf68e14..d68a5b55d 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();