Reputation: 33
Is there a way to access existing HBase table records through Hive?
Upvotes: 1
Views: 1445
Reputation: 4080
As per the Hive HBase Integration wiki page, it's possible using a create table command like the following:
CREATE TABLE hbase_table_1(key int, value string)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf1:val")
TBLPROPERTIES ("hbase.table.name" = "xyz");
However, keep in mind that creating a table like this in Hive 0.8 and before will only allow you to access data from your HBase table that was inserted via your corresponding Hive table. If you had any pre-existing data in your HBase table that wasn't inserted through the Hive table, you wouldn't be able to query it through the Hive table either.
Starting Hive 0.9, JIRA 1634, will be available which allows the Hive table to access all data present in the HBase table regardless of how it was inserted in it.
Upvotes: 2
Reputation: 34184
Yes, it is absolutely possible .Infact Hive is heavily used for that, as Hbase doesn't provide SQL functions like "JOINS" etc..Also Hive makes it easy for the users who are new to NOSQL terminology..You just have to create a table in Hive that provides a mapping with the existing Hbase table..You should be careful while creating this mapping..Properly include all the things that are present in the Hbase tables..I would like to add one important thing here..We should not think of Hive as a replacement of Hbase, as it is suitable for batch processing and not for total real time applications.
Upvotes: 2