0
votes

I have a .xml file having data like:

<book>
    <author>Gambardella, Matthew</author>
    <title>XML Developer's Guide</title>
    <genre>Computer</genre>
    <price discount="0.15">44.95</price>
    <publish_date>2000-10-01</publish_date>
    <description>An in-depth look at creating applications with XML.</description>
</book>
<book>
    <author>Knorr, Stefan</author>
    <title>Creepy Crawlies</title>
    <genre>Horror</genre>
    <price discount="0.15">4.95</price>
    <publish_date>2000-12-06</publish_date>
    <description>An anthology of horror stories about roaches,centipedes, scorpionsand other insects.</description>
</book>
<book>
    <author>Galos, Mike</author>
    <title>Visual Studio 7: A Comprehensive Guide</title>
    <genre>Computer</genre>
    <price discount="0.15">49.95</price>
    <publish_date>2001-04-16</publish_date>
    <description>Microsoft Visual Studio 7 is explored in depth, looking at how Visual Basic, Visual C++, C#, and ASP+ are integrated into a comprehensive development environment.</description>
</book>

I am trying to parse the xml through hive by creating external table on top of xml file on hdfs using serde. Please find my code below

I first added the jar

add jar hdfs://xtlinno1vftsnxg:8020/user/hdfs/hivexmlserde-1.0.5.3.jar;

CREATE EXTERNAL TABLE hive_test_xml(
. . . . . . . . . . . . . . . . . . . . . . .> col1            string,
. . . . . . . . . . . . . . . . . . . . . . .> col2            string,
. . . . . . . . . . . . . . . . . . . . . . .> col3            string)
. . . . . . . . . . . . . . . . . . . . . . .> ROW FORMAT SERDE 'com.ibm.spss.hive.serde2.xml.XmlSerDe'
. . . . . . . . . . . . . . . . . . . . . . .> WITH SERDEPROPERTIES (
. . . . . . . . . . . . . . . . . . . . . . .> "column.xpath.col1"="/book/author/text()",
. . . . . . . . . . . . . . . . . . . . . . .> "column.xpath.col2"="/book/title/text()",
. . . . . . . . . . . . . . . . . . . . . . .> "column.xpath.col3"="/book/genre/text()"
. . . . . . . . . . . . . . . . . . . . . . .> )
. . . . . . . . . . . . . . . . . . . . . . .> STORED AS
. . . . . . . . . . . . . . . . . . . . . . .> INPUTFORMAT 'com.ibm.spss.hive.serde2.xml.XmlInputFormat'
. . . . . . . . . . . . . . . . . . . . . . .> OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat'
. . . . . . . . . . . . . . . . . . . . . . .> LOCATION 'hdfs://xtlinno1vftsnxg:8020/user/poctest2/testxml2.xml'
. . . . . . . . . . . . . . . . . . . . . . .> TBLPROPERTIES (
. . . . . . . . . . . . . . . . . . . . . . .> "xmlinput.start"="<book",
. . . . . . . . . . . . . . . . . . . . . . .> "xmlinput.end"="</book>");

error that I am getting is

Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. org/apache/hadoop/hive/serde2/SerDe (state=08S01,code=1)

I am not sure how to resolve this error..Please help!!

1

1 Answers

0
votes

Most likely the metastore_db is corrupted.Set the validation to ignore and repair the table name in metastore.

set hive.msck.path.validation=ignore;
MSCK REPAIR TABLE table_name;