gpt4 book ai didi

xml - Hive XML Serde - NULLPOINTEREXCEPTION

转载 作者:可可西里 更新时间:2023-11-01 14:41:09 25 4
gpt4 key购买 nike

我是 Hadoop/Hive 的新手。我想创建一个带有 XML 输入的 Hive 脚本。所以,我有 this获取 serde 的链接。里面有一个 jar 包,我用它来做 Hive 脚本。

这就是我执行 Hive 语句的方式..

[biadmin@bng xml]$ hive

Logging initialized using configuration in jar:file:/home/biadmin/hive/lib/hive-common-0.13.1.jar!/hive-log4j.properties

hive> add jar /home/biadmin/scripts/hivexmlserde-1.0.0.0.jar;
Added /home/biadmin/scripts/hivexmlserde-1.0.0.0.jar to class path
Added resource: /home/biadmin/scripts/hivexmlserde-1.0.0.0.jar

hive> create external table if not exists xmltest (id varchar(50), name varchar(50), type varchar(50), dependency varchar(50), values varchar(50))
> ROW FORMAT SERDE 'com.ibm.spss.hive.serde2.xml.XmlSerDe'
> WITH SERDEPROPERTIES (
> "column.xpath.id"="/recs/rec/id/text()",
> "column.xpath.name"="/recs/rec/name/text()",
> "column.xpath.type"="/recs/rec/type/text()",
> "column.xpath.dependency"="/recs/rec/dependency/text()",
> "column.xpath.values"="/recs/rec/values/text()"
> )
> STORED AS
> INPUTFORMAT 'com.ibm.spss.hive.serde2.xml.XmlInputFormat'
> OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat'
> TBLPROPERTIES (
> "xmlinput.start"="<Par as",
> "xmlinput.end"="</Par>"
> );
OK
Time taken: 0.126 seconds

hive> load data local inpath '/home/biadmin/scripts/xml/playcontent.xml' into table xmltest;
Copying data from file:/home/biadmin/scripts/xml/playcontent.xml
Copying file: file:/home/biadmin/scripts/xml/playcontent.xml
Loading data to table default.xmltest
Table default.xmltest stats: [numFiles=3, numRows=0, totalSize=1842, rawDataSize=0]
OK
Time taken: 0.807 seconds

hive> select * from xmltest;
OK
Failed with exception java.io.IOException:java.lang.NullPointerException
Time taken: 0.305 seconds

hive>

我尝试使用的 XML 如下...

<Par as="val">
<recs>
<rec>
<id>servicedescription</id>
<name>Description</name>
<type>textbox</type>
<dependency>1</dependency>
<values>1</values>
</rec>
<rec>
<id>contentlist</id>
<name>Content File/s</name>
<type>selectmul</type>
<dependency>1</dependency>
<values>1</values>
</rec>
<rec>
<id>seek</id>
<name>Seek</name>
<type>checkbox</type>
<dependency>1</dependency>
<values>1</values>
</rec>
</recs>
</Par>

谁能告诉我哪里出错了?任何帮助将不胜感激。

最佳答案

尝试将这些作为 column.xpath.<your attribute-name> 的值CREATE 语句中的属性。

"column.xpath.id"="Par/recs/rec/id/text()",
"column.xpath.name"="Par/recs/rec/name/text()",
"column.xpath.type"="Par/recs/rec/type/text()",
"column.xpath.dependency"="Par/recs/rec/dependency/text()",
"column.xpath.values"="Par/recs/rec/values/text()"

我相信这个修改对你有用。

关于xml - Hive XML Serde - NULLPOINTEREXCEPTION,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25842750/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com