2014-10-10 25 views
1

我要地圖我的HBase的表來攆,這是我的了:如何在Hive中映射沒有限定符的HBase列?

CREATE EXTERNAL TABLE kutschke.bda01.twitter (
rowkey BIGINT, 
userId BIGINT, 
text STRING, 
creationTime STRING, 
isRetweet BOOLEAN, 
retweetId BIGINT 
) 
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' 
WITH SERDEPROPERTIES ('hbase.columns.mapping' = ':key, user:id, text:, time:createdAt, retweet:isRetweet, retweet:retweetId' 
TBLPROPERTIES('hbase.table.name' = 'kutschke.bda01.twitter' 

然而,「文本:」一欄中沒有得到正確映射,因爲它沒有限定。相反,我得到異常:

Logging initialized using configuration in file:/etc/hive/conf.dist/hive-log4j.properties 
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. java.lang.RuntimeException: 
MetaException(message:org.apache.hadoop.hive.serde2.SerDeException org.apache.hadoop.hive.hbase.HBaseSerDe: 
hbase column family 'text' should be mapped to Map<? extends LazyPrimitive<?, ?>,?>, 
that is the Key for the map should be of primitive type, but is mapped to string) 

我想我理解其背後映射的整列家族地圖的邏輯,但有沒有辦法正確映射與空預選賽列?如果不是,我如何需要將列族映射到MAP,以及如何檢索我真正想要的列?

回答

0

這可以通過鍵入配置單元列作爲蜂房本地地圖類型,這樣來完成:

CREATE TABLE hbase_table_1(value map<string,int>, row_key int) 
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' 
WITH SERDEPROPERTIES (
"hbase.columns.mapping" = "cf:,:key" 
); 

從映射到整個CF字段的輸出將被呈現爲JSON字符串。

更多的信息在這裏:https://cwiki.apache.org/confluence/display/Hive/HBaseIntegration#HBaseIntegration-HiveMAPtoHBaseColumnFamily