我有一个具有列族(名称,联系人)和列,名称(字符串),年龄(字符串),workStreet(字符串),workCity(字符串),workState(字符串)的hbase表。

我想创建一个外部配置单元表,该表指向具有以下各列的该hbase表。
名称(字符串),年龄(字符串),地址(结构)。

CREATE EXTERNAL TABLE hiveTable(id INT,name STRING, age STRING,
address STRUCT<Street:STRING,City:STRING,State:STRING>)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" ="Name:name,Name:age,Contact:workStreet, Contact:workCity, Contact:workState")
TBLPROPERTIES("hbase.table.name" = "hbaseTable");

遇到以下错误,
Error while processing statement: 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 3 elements while hbase.columns.mapping
has 5 elements (counting the key if implicit))

最佳答案

我尝试使用Map而不是Struct。下面是查询,

CREATE EXTERNAL TABLE hiveTable(id INT,name STRING,age STRING,
                           address MAP<String,String>)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = "Name:name,Name:,Contact:")
TBLPROPERTIES("hbase.table.name" = "hbaseTable");

关于hadoop - 如何创建指向hbase表的复杂数据类型的外部hive表?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38600116/

10-12 23:49