drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ve...@apache.org
Subject drill git commit: DRILL-2453: Handle the case where incoming has no schema in PartitionSender.
Date Mon, 16 Mar 2015 20:24:23 GMT
Repository: drill
Updated Branches:
  refs/heads/master 7b4c887e8 -> 34932e126


DRILL-2453: Handle the case where incoming has no schema in PartitionSender.


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

Branch: refs/heads/master
Commit: 34932e12619762f656c1faf3d9039888de0ad277
Parents: 7b4c887
Author: vkorukanti <venki.korukanti@gmail.com>
Authored: Sun Mar 15 13:23:03 2015 -0700
Committer: vkorukanti <venki.korukanti@gmail.com>
Committed: Sun Mar 15 13:23:03 2015 -0700

----------------------------------------------------------------------
 .../apache/drill/hbase/TestHBaseQueries.java    | 30 ++++++++++++++++++++
 .../PartitionSenderRootExec.java                | 10 ++++++-
 2 files changed, 39 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/34932e12/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
index f842acc..3f412c7 100644
--- 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
@@ -60,4 +60,34 @@ public class TestHBaseQueries extends BaseHBaseTest {
     }
 
   }
+
+
+  @Test
+  public void testWithEmptyTable() throws Exception {
+    HBaseAdmin admin = HBaseTestsSuite.getAdmin();
+    String tableName = "drill_ut_empty_table";
+    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);
+
+      setColumnWidths(new int[] {8, 15});
+      runHBaseSQLVerifyCount("SELECT row_key, count(*)\n"
+          + "FROM\n"
+          + "  hbase.`" + tableName + "` tableName GROUP BY row_key\n"
+          , 0);
+    } 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/34932e12/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/partitionsender/PartitionSenderRootExec.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/partitionsender/PartitionSenderRootExec.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/partitionsender/PartitionSenderRootExec.java
index 7df69a4..abf9cbc 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/partitionsender/PartitionSenderRootExec.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/partitionsender/PartitionSenderRootExec.java
@@ -39,6 +39,7 @@ import org.apache.drill.exec.physical.config.HashPartitionSender;
 import org.apache.drill.exec.physical.impl.BaseRootExec;
 import org.apache.drill.exec.physical.impl.SendingAccountor;
 import org.apache.drill.exec.proto.ExecProtos.FragmentHandle;
+import org.apache.drill.exec.record.BatchSchema;
 import org.apache.drill.exec.record.BatchSchema.SelectionVectorMode;
 import org.apache.drill.exec.record.FragmentWritableBatch;
 import org.apache.drill.exec.record.RecordBatch;
@@ -269,6 +270,13 @@ public class PartitionSenderRootExec extends BaseRootExec {
   }
 
   public void sendEmptyBatch(boolean isLast) {
+    BatchSchema schema = incoming.getSchema();
+    if (schema == null) {
+      // If the incoming batch has no schema (possible when there are no input records),
+      // create an empty schema to avoid NPE.
+      schema = BatchSchema.newBuilder().build();
+    }
+
     FragmentHandle handle = context.getHandle();
     StatusHandler statusHandler = new StatusHandler(sendCount, context);
     for (MinorFragmentEndpoint destination : popConfig.getDestinations()) {
@@ -280,7 +288,7 @@ public class PartitionSenderRootExec extends BaseRootExec {
           handle.getMinorFragmentId(),
           operator.getOppositeMajorFragmentId(),
           destination.getId(),
-          incoming.getSchema());
+          schema);
       stats.startWait();
       try {
         tunnel.sendRecordBatch(statusHandler, writableBatch);


Mime
View raw message