0

HBase 表规范

DESCRIPTION ENABLED {NAME => 'hbase_2_hive_names', FAMILIES => [{NAME => 'age',
DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'NONE', REPLICATION_SCOPE => '0', VERSIONS => 
'3', COMPRESSION =>  true 'NONE', MIN_VERSIONS => '0', TTL => '2147483647', KEEP_DELETED_CELLS 
=> 'false', BLOCKSIZE => '65536', IN_MEMORY => 'false', ENCODE_ON_DISK => 'true', BLOCKCACHE 
=> 'true'}, {NAME => 'id', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'NONE', 
REPLICATION_SCOPE => '0', VERSIONS => '3', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 
'2147483647', KEEP_DELETED_CELLS => 'false', BLOCKSIZE => '65536', IN_MEMORY => 'false', 
ENCODE_ON_DISK => 'true', BLOCKCACHE => 'true'}, {NAME => 'name', DATA_BLOCK_ENCODING 
=>'NONE', BLOOMFILTER => 'NONE', REPLICATION_SCOPE => '0', VERSIONS => '3', COMPRESSION => 
'NONE', MIN_VERSIONS => '0', TTL => '2147483647', KEEP_DELETED_CELLS => 'false', BLOCKSIZE => 
'65536', IN_MEMORY => 'false', ENCODE_ON_DISK => 'true', BLOCKCACHE => 'true'}]}                                                                                                                                                    

在 Hive 中创建外部表:

CREATE EXTERNAL TABLE hbase_hive_names(hbid INT, id INT,  fn STRING, ln STRING)
PARTITIONED BY (age INT) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,id:id,name:fn,name:ln,age:age")
TBLPROPERTIES("hbase.table.name" = "hbase_2_hive_names");

得到以下错误

 Error in metadata: java.lang.RuntimeException:
   MetaException(message:org.apache.hadoop.hive.serde2.SerDeException      
   org.apache.hadoop.hive.hbase.HBaseSerDe: columns has 4 elements while hbase.columns.mapping has 5 elements (counting the key if implicit)
4

2 回答 2

0

HIVE 列列表(hbid INT、id INT、fn STRING、ln STRING)= 4 列您尝试映射到 5 个限定符“hbase.columns.mapping”=“:key, id:id, name:fn, name:ln , 年龄: 年龄"

留心 ;)

于 2014-07-31T15:03:06.247 回答
-2

Hbase有行,所以你应该在喜欢这个key string时添加create external table

CREATE EXTERNAL TABLE
   hbase_hive_names(key STRING,hbid INT, id INT, fn STRING, ln STRING)
PARTITIONED BY (age INT) 
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' 
WITH SERDEPROPERTIES
   ("hbase.columns.mapping" = ":key,id:id,name:fn,name:ln,age:age")
TBLPROPERTIES("hbase.table.name" = "hbase_2_hive_names");
于 2013-04-19T09:57:23.977 回答