NoSQL
Hive not only provides a connection for data querying but also can map its external table to a NoSQL database, such as HBase
or MongoDB, with various storage handlers.
To map an existing table in HBase
, Hive uses the HBaseStorageHandler
class in the table-creation statement. An example of creating a Hive external table mapping to an existing HBase
is as follows:
> CREATE TABLE hbase_table_sample(
> id int,
> value1 string,
> value2 string,
> map_value map<string, string>
> )
> STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
> WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf1:val,cf2:val,cf3")
> TBLPROPERTIES ("hbase.table.name" = "table_name_in_hbase");
In this special CREATE TABLE
statement, the HBaseStorageHandler
class is delegating interaction with the HBase
table with HiveHBaseTableInputFormat
and HiveHBaseTableOutputFormat
. The hbase.columns.mapping
property is required to map each table column defined in the statement to the...