我从一个带有 XML SerDe 的 XML 文件创建一个带有 HIVE (Hive 2.1.1-mapr-1703) 的外部表。该文件是来自 W3C 联盟的XML 示例。
这是我创建表的代码:
add jar /mapr/localpath/hivexmlserde-1.0.5.3.jar;
USE my_db;
CREATE EXTERNAL TABLE frank_books (
category STRING,
title STRING,
language STRING,
year BIGINT
)
ROW FORMAT SERDE 'com.ibm.spss.hive.serde2.xml.XmlSerDe'
WITH SERDEPROPERTIES (
"column.xpath.category" = "/book/@category",
"column.xpath.title" = "/book/title/text()",
"column.xpath.language" = "/book/title/@lang",
"column.xpath.year" = "/book/year/text()"
)
STORED AS
INPUTFORMAT 'com.ibm.spss.hive.serde2.xml.XmlInputFormat'
OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat'
LOCATION '/mapr/localpath/database_files/xml_example'
TBLPROPERTIES (
"xmlinput.start" = "<book category",
"xmlinput.stop" = "</book>"
)
表本身存在是因为 describe 语句不会导致错误:
describe frank_books;
如下所示的简单选择语句会导致NullPointerException:
select * from my_db.frank_books;
这是输出:
OK
Failed with exception java.io.IOException:java.lang.NullPointerException
Time taken: 1.117 seconds
谁能帮忙,请向我解释错误?
谢谢,弗兰克