1
votes

I can create a Hive table with this query

CREATE TABLE hbtable(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");

And I used this query for inserting data into the table but it's not working,

insert overwrite table hbtable  select * from hbtable s where s:hive fiels="value"

How can I insert values into a HBase table through Hive table?

1
I would strongly suggest that you should go through your question once before submitting it. What's the error you are getting?And what is "s:hive"???Why do you want to select and insert the values into the same table??Tariq

1 Answers

0
votes

Follow these steps,

Step 1 :

bin/hive --auxpath /hadoop/projects/hive-0.9.0/lib/hive-hbase-handler-0.9.0.jar,/hadoop/projects/hive-0.9.0/lib/hbase-0.92.0.jar,/hadoop/projects/hive-0.9.0/lib/zookeeper-3.3.4.jar,/hadoop/projects/hive-0.9.0/lib/guava-r09.jar -hiveconf hbase.master=localhost:60000
STep 2 :
hive> 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");

Step 3 :
hive> INSERT OVERWRITE TABLE hbase_table_1 SELECT * FROM xyz WHERE key=1;

Note : I am running hive-0.9.0 and hbase-0.94.4 on a single Ubuntu box.