0
votes

I am trying to map a table in hive to view an hbase table. I did this without a problem with several columns, but am unsure how to manage with a counter column. Is this possible?

When I scan the hbase table an example value of the counter column is \x00\x00\x00\x00\x00\x00\x00\x01.

I suspect I am setting the column type incorrectly in the hive table. I have tried int and string (both show only nulls in the hive view). Is there a better way at getting the number of increments from this value? The ideal world would be a column in hive that is the sum of all the increments, i assume.

It is entirely possible I am misunderstanding what is possible in viewing the counter (or how the counter was originally setup).

1

1 Answers

1
votes

Ended up finding answer through this link on cloudera community.

Answer is to define counter column in hive table as bigint and define the SERDEPROPERTIES with '#b' added to the end to indicate the hbase column type is binary.

For example:

create external table md_extract_file_status ( table_key string, fl_counter bigint)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ('hbase.columns.mapping' = ':key,colfam:FL_Counter#b )
TBLPROPERTIES('hbase.table.name' ='HBTABLE');