Reply
Highlighted
New Contributor
Posts: 1
Registered: ‎04-10-2015

HBase Hive Integration

[ Edited ]

I have created a HBase by mentioning the default versions as 5

 

create 'tablename',{NAME => 'cf', VERSIONS => 5}


and inserted two rows(row1 and row2)

 

put 'tablename','row1','cf:id','row1id'
put 'tablename','row1','cf:name','row1name'
put 'tablename','row2','cf:id','row2id'
put 'tablename','row2','cf:name','row2name'
put 'tablename','row2','cf:name','row2nameupdate'
put 'tablename','row2','cf:name','row2nameupdateagain'

 

Tried to select the data by using scan and I'm getting the latest updated data.
and when I tried to select the different versions data by using the below command I got the different versions data.

 

scan 'tablename',{RAW => true, VERSIONS => 5}

Now created a Hive External table to point to this HBase table

 

CREATE EXTERNAL TABLE hive_timestampupdate(key int, value string)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf:name")
TBLPROPERTIES ("hbase.table.name" = "tablename");
select * from hive_timestampupdate;

When I queried the table hive_timestampupdate, I'm able to see the data.

By default here I'm getting the latest updated data based on timestamp.
Here also I want to query the data of different versions.

**Hive command that will fetch the different versions data of HBase.**

Thanks in Advance.

Posts: 1,903
Kudos: 435
Solutions: 307
Registered: ‎07-31-2013

Re: HBase Hive Integration

This is currently not possible to perform in Hive. The record reader builds scans only with the latest version (default scan) [1]

[1] - https://github.com/cloudera/hive/blob/cdh5.4.0-release/hbase-handler/src/java/org/apache/hadoop/hive...