无法有效地映射HIve表中的HBase行键

时间:2018-02-26 19:11:15

标签: hadoop hive hbase hive-serde

我有一个HBase表,其中rowkey看起来像这样。

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

我使用以下查询创建一个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");

当我查询表格时,我得到以下结果

select * from hb;

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

这对我来说很奇怪。为什么serde无法映射HBase密钥的全部内容?在第二个':'

之后,hive表缺少所有内容

有人遇到过类似的问题吗?

1 个答案:

答案 0 :(得分:1)

我尝试在Hbase 1.1.2和Hive 1.2.1000上重新创建你的场景,它按预期工作,我能够从hive获得整个rowkey

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

因为我有08:516485815:2013作为rowkey,我创建了hive表

 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         |
    +--------------------+-----------+--+

你能否确保你的hbase表rowkey在第二个之后有数据。