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)
答案 0 :(得分:0)
HIVE列的列表(hbid INT,id INT,fn STRING,ln STRING)=您尝试映射到5个限定符的4列“hbase.columns.mapping”=“:key,id:id,name:fn,姓名:ln,年龄:年龄“
要注意;)
答案 1 :(得分:-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");