aboutsummaryrefslogtreecommitdiff
path: root/contrib/storage-hbase
diff options
context:
space:
mode:
authorArina Ielchiieva <arina.yelchiyeva@gmail.com>2018-08-17 17:04:30 +0300
committerArina Ielchiieva <arina.yelchiyeva@gmail.com>2018-08-27 09:56:53 +0300
commit8bcb103a0e3bcc5f85a03cbed3c6c0cea254ec4e (patch)
tree428914b1f08ea4d0ecda20cddc3c668c5c21075a /contrib/storage-hbase
parentddb35ce71837376c7caef28c25327ba556bb32f2 (diff)
DRILL-6492: Ensure schema / workspace case insensitivity in Drill
1. StoragePluginsRegistryImpl was updated: a. for backward compatibility at init to convert all existing storage plugins names to lower case, in case of duplicates, to log warning and skip the duplicate. b. to wrap persistent plugins registry into case insensitive store wrapper (CaseInsensitivePersistentStore) to ensure all given keys are converted into lower case when performing insert, update, delete, search operations. c. to load system storage plugins dynamically by @SystemStorage annotation. 2. StoragePlugins class was updated to stored storage plugins configs by name in case insensitive map. 3. SchemaUtilities.searchSchemaTree method was updated to convert all schema names into lower case to ensure that are they are matched case insensitively (all schemas are stored in Drill in lower case). 4. FileSystemConfig was updated to store workspaces by name in case insensitive hash map. 5. All plugins schema factories are now extend AbstractSchemaFactory to ensure that given schema name is converted to lower case. 6. New method areTableNamesAreCaseInsensitive was added to AbstractSchema to indicate if schema tables names are case insensitive. By default, false. Schema implementation is responsible for table names case insensitive search in case it supports one. Currently, information_schema, sys and hive do so. 7. System storage plugins (information_schema, sys) were refactored to ensure their schema, table names are case insensitive, also the annotation @SystemPlugin and additional constructor were added to allow dynamically load system plugins at storage plugin registry during init phase. 8. MetadataProvider was updated to concert all schema filter conditions into lower case to ensure schema would be matched case insensitively. 9. ShowSchemasHandler, ShowTablesHandler, DescribeTableHandler were updated to ensure schema / tables names (this depends if schema supports case insensitive table names) would be found case insensitively. git closes #1439
Diffstat (limited to 'contrib/storage-hbase')
-rw-r--r--contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseSchemaFactory.java26
1 files changed, 12 insertions, 14 deletions
diff --git a/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseSchemaFactory.java b/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseSchemaFactory.java
index b8e825bfb..46e04441f 100644
--- a/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseSchemaFactory.java
+++ b/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseSchemaFactory.java
@@ -24,36 +24,34 @@ import java.util.Set;
import org.apache.calcite.schema.SchemaPlus;
import org.apache.calcite.schema.Table;
import org.apache.drill.exec.store.AbstractSchema;
+import org.apache.drill.exec.store.AbstractSchemaFactory;
import org.apache.drill.exec.store.SchemaConfig;
-import org.apache.drill.exec.store.SchemaFactory;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.client.Admin;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets;
-public class HBaseSchemaFactory implements SchemaFactory {
- static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(HBaseSchemaFactory.class);
+public class HBaseSchemaFactory extends AbstractSchemaFactory {
+ private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(HBaseSchemaFactory.class);
- final String schemaName;
- final HBaseStoragePlugin plugin;
+ private final HBaseStoragePlugin plugin;
public HBaseSchemaFactory(HBaseStoragePlugin plugin, String name) throws IOException {
+ super(name);
this.plugin = plugin;
- this.schemaName = name;
}
@Override
public void registerSchemas(SchemaConfig schemaConfig, SchemaPlus parent) throws IOException {
- HBaseSchema schema = new HBaseSchema(schemaName);
- SchemaPlus hPlus = parent.add(schemaName, schema);
+ HBaseSchema schema = new HBaseSchema(getName());
+ SchemaPlus hPlus = parent.add(getName(), schema);
schema.setHolder(hPlus);
}
class HBaseSchema extends AbstractSchema {
- public HBaseSchema(String name) {
- super(ImmutableList.<String>of(), name);
+ HBaseSchema(String name) {
+ super(Collections.emptyList(), name);
}
public void setHolder(SchemaPlus plusOfThis) {
@@ -73,13 +71,13 @@ public class HBaseSchemaFactory implements SchemaFactory {
public Table getTable(String name) {
HBaseScanSpec scanSpec = new HBaseScanSpec(name);
try {
- return new DrillHBaseTable(schemaName, plugin, scanSpec);
+ return new DrillHBaseTable(getName(), plugin, scanSpec);
} catch (Exception e) {
// Calcite firstly looks for a table in the default schema, if the table was not found,
// it looks in the root schema.
// If the table does not exist, a query will fail at validation stage,
// so the error should not be thrown here.
- logger.warn("Failure while loading table '{}' for database '{}'.", name, schemaName, e.getCause());
+ logger.warn("Failure while loading table '{}' for database '{}'.", name, getName(), e.getCause());
return null;
}
}
@@ -94,7 +92,7 @@ public class HBaseSchemaFactory implements SchemaFactory {
}
return tableNames;
} catch (Exception e) {
- logger.warn("Failure while loading table names for database '{}'.", schemaName, e.getCause());
+ logger.warn("Failure while loading table names for database '{}'.", getName(), e.getCause());
return Collections.emptySet();
}
}