Here is a simple example of querying Hbase data using Hive
Step 1:
Create a table in HBase
$hbase shell hbase(main):002:0>create 'hbase_table','colfam1'
Step 2:
Insert data into HBase table (I am randomly populating the table)
hbase(main):002:0> for i in 1..100 do for j in 1..100 do \ put 'hbase_table', "row-#{i}#{j}","colfam1:val","#{j}" end end
Step 3:
Create a table in Hive, which will query from our HBase table ‘hbase_table’
CREATE EXTERNAL TABLE hive_table_1(key string, value string) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ("hbase.columns.mapping" = "colfam1:val") TBLPROPERTIES("hbase.table.name" = "hbase_table");
Step 4:
SELECT * FROM hive_table_1;
Comment below if you find this blog useful.
Greetings! Very helpful advice in this particular post! It’s the little changes that will make the greatest changes. Many thanks for sharing!