Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Split hbase row key when mapping to hive table

Split hbase row key when mapping to hive table

New Contributor

Hi guys,

I have a table in hbase like shown below:

hbase(main):005:0> scan 'glookups'

ROW COLUMN+CELL
UDS.WT_PRD_MD.MR column=lk:lval, timestamp=1526974749860, value=Denver
UDS.WT_PRD_MD.MR column=lk:val, timestamp=1526974739603, value=DN
1 row(s) in 0.0230 seconds

now I wanted it to map to hive table and the script is shown below:

create EXTERNAL TABLE global_lookups(key String,val String,lvl String)

STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'

WITH SERDEPROPERTIES

("hbase.columns.mapping"=":key,lk:lvl,lk:val")TBLPROPERTIES("hbase.table.name"="EOS:globallookups");


which works fine .But my scenario is bit different I want the row key to be splitted and stored in different columns in hive for example if this my row key UDS.WT_PRD_MD.MR

I want UDS should be in one column

WT_PRD_MD in one column

and the value of lk:lval in one column

and the value of lk:val in another column

I wrote the following script but it's not working

create EXTERNAL TABLE global_lookups(sorname String,fieldname String,fieldCode String,fieldDescription String)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES
("hbase.columns.mapping"=":key.subString(0,3),:key.subString(5,14),lk:lvl,lk:val")TBLPROPERTIES("hbase.table.name"="EOS:globallookups");

How can I achieve this ???

Don't have an account?
Coming from Hortonworks? Activate your account here