hive> CREATE TABLE hperson(id string, name string,email string) STORED BY ‘org.apache.hadoop.hive.hbase.HBaseStorageHandler‘ WITH SERDEPROPERTIES ("hbase.columns.mapping" =
":id,cf1:name,cf2:email") TBLPROPERTIES ("hbase.table.name" = "hbperson");、
FAILED: Error in metadata: java.lang.RuntimeException: MetaException(message:org.apache.hadoop.hive.serde2.SerDeException org.apache.hadoop.hive.hbase.HBaseSerDe: columns has
3 elements while hbase.columns.mapping has 4 elements (counting the key if implicit))
在创建hive/hbase相关联的表时,hbase表结构默认会有一个字段key。假设没有一个显示的字段‘key‘那么在创建表的进修,会自己创建,这样hive相应的表就会出现故障,所以在hive相应的表里一定要加上key这个字段,为了避免这个问题,在hbase表结构里能够显示的加入‘key‘字段,这样不easy出问题。
正确的格式例如以下:
CREATE TABLE hperson1(key string,id string, name string,email string) STORED BY ‘org.apache.hadoop.hive.hbase.HBaseStorageHandler‘ WITH SERDEPROPERTIES ("hbase.columns.mapping" = "cf0:id,cf1:name,cf2:email") TBLPROPERTIES ("hbase.table.name"
= "hbperson1");
或者:
CREATE TABLE hperson1(key string,id string, name string,email string) STORED BY ‘org.apache.hadoop.hive.hbase.HBaseStorageHandler‘ WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf0:id,cf1:name,cf2:email") TBLPROPERTIES
("hbase.table.name" = "hbperson1");