0

I have a HBase table where the rowkey looks like this.

08:516485815:2013 1
06:260070837:2014 1
00:338289200:2014 1

I create a Hive link table using the below query.

create external table hb
(key string,value string)
stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
with serdeproperties("hbase.columns.mapping"=":key,e:-1")
tblproperties("hbase.table.name"="hbaseTable");

When I query the table I get the below result

select * from hb;

08:516485815 1
06:260070837 1
00:338289200 1

This is very strange to me. Why the serde is not able to map the whole content of the HBase key? The hive table is missing everything after the second ':'

Has anybody faced a similar kind of issue?

E_net4
  • 27,810
  • 13
  • 101
  • 139
Alex Raj Kaliamoorthy
  • 2,035
  • 3
  • 29
  • 46

1 Answers1

1

I tried by recreating your scenario on Hbase 1.1.2 and Hive 1.2.1000,it works as expected and i am able to get the whole rowkey from hive.

hbase>   create 'hbaseTable','e'
hbase>   put 'hbaseTable','08:516485815:2013','e:-1','1'
hbase>   scan 'hbaseTable'
    ROW                                                         COLUMN+CELL
     08:516485815:2013                                          column=e:-1, timestamp=1519675029451, value=1
    1 row(s) in 0.0160 seconds

As i'm having 08:516485815:2013 as rowkey and i have created hive table

 hive> create external table hb
    (key string,value string)
    stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
    with serdeproperties("hbase.columns.mapping"=":key,e:-1")
    tblproperties("hbase.table.name"="hbaseTable");
 hive> select * from hb;
    +--------------------+-----------+--+
    |       hb.key       | hb.value  |
    +--------------------+-----------+--+
    | 08:516485815:2013  | 1         |
    +--------------------+-----------+--+

Can you once make sure your hbase table rowkey having the data after second :.

notNull
  • 30,258
  • 4
  • 35
  • 50
  • Hbase has the key like how I have mentioned. – Alex Raj Kaliamoorthy Feb 27 '18 at 07:43
  • If I follow the same step of hbase table and the hive table creation like you, I get the same result like yours. But the HBase table that I use has values as json. Dont know if that makes any difference. Also the row keys are combination of both the types i.e. `08:516485815:2013` and `08:516485815` – Alex Raj Kaliamoorthy Feb 27 '18 at 08:00
  • Could you share some sample hbase rows..scan ‘table-name’,{LIMIT=>10} – notNull Feb 27 '18 at 12:37