|
|
-
HBase-Hive integration - fetching long values in HBase as bigint in HiveAshish Nigam 2013-02-14, 14:23
Hi,
I am storing counters (long value) in HBase table. I have created Hive Table like this - CREATE EXTERNAL TABLE hbase_hive_counters(value map<string,bigint>, row_key int) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ("hbase.columns.mapping" = "stats-daily:,:key") TBLPROPERTIES("hbase.table.name" = "counters"); The problem is that all counter values are coming as NULL if I perform select on this table. If I change the DDL to get string, I do see counter values.Modified DDL is like this - CREATE EXTERNAL TABLE hbase_hive_counters(value map<string,string>, row_key int) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ("hbase.columns.mapping" = "stats-daily:,:key") TBLPROPERTIES("hbase.table.name" = "counters"); Now I do see the values. For example, here's hive> select * from hbase_hive_counters; OK {"20130209-C":"\u0000\u0000\u0000\u0000\u0000\u0000\u0000�","20130209-C-U-8077639":"\u0000\u0000\u0000\u0000\u0000\u0000\u0000�","20130210":"\u0000\u0000\u0000\u0000\u0000\u0000\u0000�","20130210-U-8077639":"\u0000\u0000\u0000\u0000\u0000\u0000\u0000 �"} 2000 {"20130210":"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0012","20130210-U-8077639":"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0012"} 2018 I even tried this query when the counter type is string in the HIVE table - select cast(value["20130210"] as bigint) from hbase_hive_counters where row_key=2000; The answer is again, NULL. How do I get counter values in HIVE as bigint? Thanks Ashish |