aboutsummaryrefslogtreecommitdiff
path: root/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseUtils.java
diff options
context:
space:
mode:
authorVitalii Diravka <vitalii.diravka@gmail.com>2017-10-02 14:14:54 +0000
committerPaul Rogers <progers@maprtech.com>2017-10-11 13:25:42 -0700
commitfe79a633a3da8b4f6db50454fde64c30c73233bb (patch)
tree18fbbc12ac9f6d03d062ce0b4c4aa6cb51bbc0ff /contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseUtils.java
parent42f7af22fc5d713aac07e057fd374ccd674e40df (diff)
DRILL-5775: Select * query on a maprdb binary table fails
- The common HBase/MapR-DB_binary verifyColumns() method; - MapRDBBinaryTable is introduced for the purpose of expanding the wildcard on the planning stage; - AbstractHBaseDrillTable class for MapRDBBinaryTable and DrillHBaseTable. closes #973
Diffstat (limited to 'contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseUtils.java')
-rw-r--r--contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseUtils.java27
1 files changed, 26 insertions, 1 deletions
diff --git a/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseUtils.java b/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseUtils.java
index 0d804cde7..fc8d09d6f 100644
--- a/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseUtils.java
+++ b/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseUtils.java
@@ -1,4 +1,4 @@
-/**
+/*
* 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
@@ -22,7 +22,10 @@ import java.nio.charset.CharacterCodingException;
import java.util.List;
import org.apache.drill.common.exceptions.DrillRuntimeException;
+import org.apache.drill.common.expression.SchemaPath;
+import org.apache.drill.exec.util.Utilities;
import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.filter.Filter;
import org.apache.hadoop.hbase.filter.FilterList;
import org.apache.hadoop.hbase.filter.ParseFilter;
@@ -139,4 +142,26 @@ public class HBaseUtils {
return Bytes.compareTo(left, right) < 0 ? left : right;
}
+
+ /**
+ * Verify the presence of a column family in the schema path of the hbase table or whether the schema path is
+ * the row key column.
+ *
+ * @param columns List of the selected columns
+ * @param hTableDesc HTableDescriptor of HBase/MapR-DB_binary table (consists the details about that table)
+ * @throws DrillRuntimeException if column family does not exist, or is not row_key column.
+ */
+ public static void verifyColumns(List<SchemaPath> columns, HTableDescriptor hTableDesc) {
+ if (Utilities.isStarQuery(columns)) {
+ return;
+ }
+ for (SchemaPath column : columns) {
+ if (!(column.equals(DrillHBaseConstants.ROW_KEY_PATH) ||
+ hTableDesc.hasFamily(HBaseUtils.getBytes(column.getRootSegment().getPath())))) {
+ DrillRuntimeException.format("The column family '%s' does not exist in HBase table: %s .",
+ column.getRootSegment().getPath(), hTableDesc.getNameAsString());
+ }
+ }
+ }
+
}