Class HbaseTableNameUtils
- java.lang.Object
-
- com.amazonaws.athena.connectors.hbase.HbaseTableNameUtils
-
public final class HbaseTableNameUtils extends Object
This class helps with resolving the differences in casing between HBase and Presto. Presto expects all databases, tables, and columns to be lower case. This class allows us to resolve HBase tables which may have captial letters in them without issue. It does so by fetching all table names and doing a case insensitive search over them. It will first try to do a targeted get to reduce the penalty for tables which don't have capitalization. Modeled off of DynamoDBTableResolver.java TODO add caching
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
ENABLE_CASE_INSENSITIVE_MATCH
protected static String
NAMESPACE_QUALIFIER
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.apache.hadoop.hbase.TableName
getHbaseTableName(Map<String,String> configOptions, HBaseConnection conn, TableName athTableName)
Gets the hbase table name from Athena table name.static org.apache.hadoop.hbase.TableName
getQualifiedTable(TableName tableName)
Helper which goes from an Athena Federation SDK TableName to an HBase TableName.static org.apache.hadoop.hbase.TableName
getQualifiedTable(String schema, String table)
Helper which goes from a schema and table name to an HBase TableNamestatic String
getQualifiedTableName(TableName tableName)
Helper which goes from an Athena Federation SDK TableName to an HBase table name string.static String
getQualifiedTableName(String schema, String table)
Helper which goes from a schema and table name to an HBase table name stringprotected static org.apache.hadoop.hbase.TableName
tryCaseInsensitiveSearch(HBaseConnection conn, TableName tableName)
Performs a case insensitive table search by listing all table names in the schema (namespace), mapping them to their lowercase transformation, and then mapping the given tableName back to a unique table.
-
-
-
Field Detail
-
NAMESPACE_QUALIFIER
protected static final String NAMESPACE_QUALIFIER
- See Also:
- Constant Field Values
-
ENABLE_CASE_INSENSITIVE_MATCH
protected static final String ENABLE_CASE_INSENSITIVE_MATCH
- See Also:
- Constant Field Values
-
-
Method Detail
-
getQualifiedTableName
public static String getQualifiedTableName(String schema, String table)
Helper which goes from a schema and table name to an HBase table name string- Parameters:
schema
- a schema nametable
- the name of the table- Returns:
-
getQualifiedTableName
public static String getQualifiedTableName(TableName tableName)
Helper which goes from an Athena Federation SDK TableName to an HBase table name string.- Parameters:
tableName
- An Athena Federation SDK TableName.- Returns:
- The corresponding HBase table name string.
-
getQualifiedTable
public static org.apache.hadoop.hbase.TableName getQualifiedTable(String schema, String table)
Helper which goes from a schema and table name to an HBase TableName- Parameters:
schema
- the schema nametable
- the name of the table- Returns:
- The corresponding HBase TableName
-
getQualifiedTable
public static org.apache.hadoop.hbase.TableName getQualifiedTable(TableName tableName)
Helper which goes from an Athena Federation SDK TableName to an HBase TableName.- Parameters:
tableName
- An Athena Federation SDK TableName.- Returns:
- The corresponding HBase TableName.
-
getHbaseTableName
public static org.apache.hadoop.hbase.TableName getHbaseTableName(Map<String,String> configOptions, HBaseConnection conn, TableName athTableName) throws IOException
Gets the hbase table name from Athena table name. This is to allow athena to query uppercase table names (since athena does not support them). If an hbase table name is found with the athena table name, it is returned. Otherwise, tryCaseInsensitiveSearch is used to find the corresponding hbase table.- Parameters:
tableName
- the case insensitive table name- Returns:
- the hbase table name
- Throws:
IOException
-
tryCaseInsensitiveSearch
protected static org.apache.hadoop.hbase.TableName tryCaseInsensitiveSearch(HBaseConnection conn, TableName tableName) throws IOException
Performs a case insensitive table search by listing all table names in the schema (namespace), mapping them to their lowercase transformation, and then mapping the given tableName back to a unique table. To prevent ambiguity, an IllegalStateException is thrown if multiple tables map to the given tableName.- Parameters:
conn
- the HBaseConnection used to retrieve the tablestableName
- The Athena TableName to find the mapping to- Returns:
- The HBase TableName containing the found HBase table and the Athena Schema (namespace)
- Throws:
IOException
-
-