HBase到Hive集成失败

时间:2019-02-20 10:15:43

标签: hadoop hive hbase bigdata hiveql

我在“ hbase”表中有行,列族h1,具有两个值id和名称 “ hbase_sample”。 我想在带有ID和名称列的配置单元中创建外部表,但我不 要写行或关键字段。

hive> create external table sample (id string,name string)
    > STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
    > with serdeproperties ("hbase.columns.mapping"=":key,h1:id,h1:name")
    > tblproperties("hbase.table.name"="sample_hbase");

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: columns has 2 elements while 
hbase.columns.mapping has 3 elements (counting the key if implicit))

1 个答案:

答案 0 :(得分:0)

通过看到错误消息,似乎HBase具有三列,如rowid,id和name。当您创建具有两列的配置单元表时,即id和name。 创建具有所有三列的Hive表,并将其命名为table_name_temp表。临时表存在后,从配置单元中的临时表创建两列表,然后删除临时表。看看此解决方案是否适合您。