Hive XML Serde : Parsing error when loading xml content
up vote
0
down vote
favorite
I am trying to load the following XML content using SerDe with Hive :
<?xml version="1.0"?>
<RootTag xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.website.com/service">
<Code>123</Code>
<ParentElement>
<Entity>
<EntityId>A</EntityId>
<EntityCode i:nil="true"/>
</Entity>
<Entity>
<EntityId>M</EntityId>
<EntityCode i:nil="true"/>
</Entity>
</ParentElement>
</RootTag>
The hive table was created as follows:
CREATE EXTERNAL TABLE database.mytable(
code String,
Entity array<struct<Entity:struct<EntityId:String,EntityCode:String>>>
)
ROW FORMAT SERDE 'com.ibm.spss.hive.serde2.xml.XmlSerDe'
WITH SERDEPROPERTIES
(
"column.xpath.Code" = "/RootTag/Code/text()",
"column.xpath.ParentElement" = "/RootTag/ParentElement"
)
STORED AS
INPUTFORMAT 'com.ibm.spss.hive.serde2.xml.XmlInputFormat'
OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat'
LOCATION '/xml_content/'
TBLPROPERTIES ("xmlinput.start" = "<RootTag", "xmlinput.end" = "</RootTag>");
I have 2 issues:
- when I specify the "xmlinput.start" as specified above, it doesn't work. I had to remove manually the content "xmlns:i = ... /service" next to the "RootTage" in order to start parsing the xml.
- Even though, there is another issue with "EntityCode" attribute. I am getting the error:
Caused by: org.apache.hive.service.cli.HiveSQLException:
java.io.IOException:
org.apache.hadoop.hive.serde2.SerDeException:
java.lang.RuntimeException:
org.xml.sax.SAXParseException;
lineNumber: 41;
columnNumber: 33;
The prefix "i" for attribute "i:nil" associated with an element type "ParentCode" is not bound.
What am I doing wrong? I would appreciate your suggestions and comments regarding this.
xml parsing hadoop hive hive-serde
New contributor
add a comment |
up vote
0
down vote
favorite
I am trying to load the following XML content using SerDe with Hive :
<?xml version="1.0"?>
<RootTag xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.website.com/service">
<Code>123</Code>
<ParentElement>
<Entity>
<EntityId>A</EntityId>
<EntityCode i:nil="true"/>
</Entity>
<Entity>
<EntityId>M</EntityId>
<EntityCode i:nil="true"/>
</Entity>
</ParentElement>
</RootTag>
The hive table was created as follows:
CREATE EXTERNAL TABLE database.mytable(
code String,
Entity array<struct<Entity:struct<EntityId:String,EntityCode:String>>>
)
ROW FORMAT SERDE 'com.ibm.spss.hive.serde2.xml.XmlSerDe'
WITH SERDEPROPERTIES
(
"column.xpath.Code" = "/RootTag/Code/text()",
"column.xpath.ParentElement" = "/RootTag/ParentElement"
)
STORED AS
INPUTFORMAT 'com.ibm.spss.hive.serde2.xml.XmlInputFormat'
OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat'
LOCATION '/xml_content/'
TBLPROPERTIES ("xmlinput.start" = "<RootTag", "xmlinput.end" = "</RootTag>");
I have 2 issues:
- when I specify the "xmlinput.start" as specified above, it doesn't work. I had to remove manually the content "xmlns:i = ... /service" next to the "RootTage" in order to start parsing the xml.
- Even though, there is another issue with "EntityCode" attribute. I am getting the error:
Caused by: org.apache.hive.service.cli.HiveSQLException:
java.io.IOException:
org.apache.hadoop.hive.serde2.SerDeException:
java.lang.RuntimeException:
org.xml.sax.SAXParseException;
lineNumber: 41;
columnNumber: 33;
The prefix "i" for attribute "i:nil" associated with an element type "ParentCode" is not bound.
What am I doing wrong? I would appreciate your suggestions and comments regarding this.
xml parsing hadoop hive hive-serde
New contributor
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to load the following XML content using SerDe with Hive :
<?xml version="1.0"?>
<RootTag xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.website.com/service">
<Code>123</Code>
<ParentElement>
<Entity>
<EntityId>A</EntityId>
<EntityCode i:nil="true"/>
</Entity>
<Entity>
<EntityId>M</EntityId>
<EntityCode i:nil="true"/>
</Entity>
</ParentElement>
</RootTag>
The hive table was created as follows:
CREATE EXTERNAL TABLE database.mytable(
code String,
Entity array<struct<Entity:struct<EntityId:String,EntityCode:String>>>
)
ROW FORMAT SERDE 'com.ibm.spss.hive.serde2.xml.XmlSerDe'
WITH SERDEPROPERTIES
(
"column.xpath.Code" = "/RootTag/Code/text()",
"column.xpath.ParentElement" = "/RootTag/ParentElement"
)
STORED AS
INPUTFORMAT 'com.ibm.spss.hive.serde2.xml.XmlInputFormat'
OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat'
LOCATION '/xml_content/'
TBLPROPERTIES ("xmlinput.start" = "<RootTag", "xmlinput.end" = "</RootTag>");
I have 2 issues:
- when I specify the "xmlinput.start" as specified above, it doesn't work. I had to remove manually the content "xmlns:i = ... /service" next to the "RootTage" in order to start parsing the xml.
- Even though, there is another issue with "EntityCode" attribute. I am getting the error:
Caused by: org.apache.hive.service.cli.HiveSQLException:
java.io.IOException:
org.apache.hadoop.hive.serde2.SerDeException:
java.lang.RuntimeException:
org.xml.sax.SAXParseException;
lineNumber: 41;
columnNumber: 33;
The prefix "i" for attribute "i:nil" associated with an element type "ParentCode" is not bound.
What am I doing wrong? I would appreciate your suggestions and comments regarding this.
xml parsing hadoop hive hive-serde
New contributor
I am trying to load the following XML content using SerDe with Hive :
<?xml version="1.0"?>
<RootTag xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.website.com/service">
<Code>123</Code>
<ParentElement>
<Entity>
<EntityId>A</EntityId>
<EntityCode i:nil="true"/>
</Entity>
<Entity>
<EntityId>M</EntityId>
<EntityCode i:nil="true"/>
</Entity>
</ParentElement>
</RootTag>
The hive table was created as follows:
CREATE EXTERNAL TABLE database.mytable(
code String,
Entity array<struct<Entity:struct<EntityId:String,EntityCode:String>>>
)
ROW FORMAT SERDE 'com.ibm.spss.hive.serde2.xml.XmlSerDe'
WITH SERDEPROPERTIES
(
"column.xpath.Code" = "/RootTag/Code/text()",
"column.xpath.ParentElement" = "/RootTag/ParentElement"
)
STORED AS
INPUTFORMAT 'com.ibm.spss.hive.serde2.xml.XmlInputFormat'
OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat'
LOCATION '/xml_content/'
TBLPROPERTIES ("xmlinput.start" = "<RootTag", "xmlinput.end" = "</RootTag>");
I have 2 issues:
- when I specify the "xmlinput.start" as specified above, it doesn't work. I had to remove manually the content "xmlns:i = ... /service" next to the "RootTage" in order to start parsing the xml.
- Even though, there is another issue with "EntityCode" attribute. I am getting the error:
Caused by: org.apache.hive.service.cli.HiveSQLException:
java.io.IOException:
org.apache.hadoop.hive.serde2.SerDeException:
java.lang.RuntimeException:
org.xml.sax.SAXParseException;
lineNumber: 41;
columnNumber: 33;
The prefix "i" for attribute "i:nil" associated with an element type "ParentCode" is not bound.
What am I doing wrong? I would appreciate your suggestions and comments regarding this.
xml parsing hadoop hive hive-serde
xml parsing hadoop hive hive-serde
New contributor
New contributor
edited Nov 19 at 17:06
E_net4 is kind and welcoming
11.2k63468
11.2k63468
New contributor
asked Nov 19 at 14:03
ilmar
11
11
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
There are few things.
- I think the root tag with namespace is only supported on version 1.5.0.3 or greater. check the following link https://github.com/dvasilen/Hive-XML-SerDe/issues/15
- I am don't think it supports the
i:nil="true"
- Mapping of column should match the column name and it's case sensitive.
column.xpath.Code
andcode
won't work. Also there is no corrosponding column forcolumn.xpath.ParentElement
So what you need to do?
- Upgrade your serde.
- replace
<EntityCode i:nil="true"/>
to<EntityCode/>
in your xml - Fix the code as mentioned below
Code
CREATE EXTERNAL TABLE temp.test_xml(
code String,
Entity array<struct<Entity:struct<EntityId:String,EntityCode:String>>>
)
ROW FORMAT SERDE 'com.ibm.spss.hive.serde2.xml.XmlSerDe'
WITH SERDEPROPERTIES
(
"column.xpath.code" = "/RootTag/Code/text()",
"column.xpath.Entity" = "/RootTag/ParentElement/Entity"
)
STORED AS
INPUTFORMAT 'com.ibm.spss.hive.serde2.xml.XmlInputFormat'
OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat'
LOCATION '/tmp/test_xml1/table/'
TBLPROPERTIES (
"xmlinput.start"="<RootTag",
"xmlinput.end"="</RootTag>");
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
There are few things.
- I think the root tag with namespace is only supported on version 1.5.0.3 or greater. check the following link https://github.com/dvasilen/Hive-XML-SerDe/issues/15
- I am don't think it supports the
i:nil="true"
- Mapping of column should match the column name and it's case sensitive.
column.xpath.Code
andcode
won't work. Also there is no corrosponding column forcolumn.xpath.ParentElement
So what you need to do?
- Upgrade your serde.
- replace
<EntityCode i:nil="true"/>
to<EntityCode/>
in your xml - Fix the code as mentioned below
Code
CREATE EXTERNAL TABLE temp.test_xml(
code String,
Entity array<struct<Entity:struct<EntityId:String,EntityCode:String>>>
)
ROW FORMAT SERDE 'com.ibm.spss.hive.serde2.xml.XmlSerDe'
WITH SERDEPROPERTIES
(
"column.xpath.code" = "/RootTag/Code/text()",
"column.xpath.Entity" = "/RootTag/ParentElement/Entity"
)
STORED AS
INPUTFORMAT 'com.ibm.spss.hive.serde2.xml.XmlInputFormat'
OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat'
LOCATION '/tmp/test_xml1/table/'
TBLPROPERTIES (
"xmlinput.start"="<RootTag",
"xmlinput.end"="</RootTag>");
add a comment |
up vote
0
down vote
There are few things.
- I think the root tag with namespace is only supported on version 1.5.0.3 or greater. check the following link https://github.com/dvasilen/Hive-XML-SerDe/issues/15
- I am don't think it supports the
i:nil="true"
- Mapping of column should match the column name and it's case sensitive.
column.xpath.Code
andcode
won't work. Also there is no corrosponding column forcolumn.xpath.ParentElement
So what you need to do?
- Upgrade your serde.
- replace
<EntityCode i:nil="true"/>
to<EntityCode/>
in your xml - Fix the code as mentioned below
Code
CREATE EXTERNAL TABLE temp.test_xml(
code String,
Entity array<struct<Entity:struct<EntityId:String,EntityCode:String>>>
)
ROW FORMAT SERDE 'com.ibm.spss.hive.serde2.xml.XmlSerDe'
WITH SERDEPROPERTIES
(
"column.xpath.code" = "/RootTag/Code/text()",
"column.xpath.Entity" = "/RootTag/ParentElement/Entity"
)
STORED AS
INPUTFORMAT 'com.ibm.spss.hive.serde2.xml.XmlInputFormat'
OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat'
LOCATION '/tmp/test_xml1/table/'
TBLPROPERTIES (
"xmlinput.start"="<RootTag",
"xmlinput.end"="</RootTag>");
add a comment |
up vote
0
down vote
up vote
0
down vote
There are few things.
- I think the root tag with namespace is only supported on version 1.5.0.3 or greater. check the following link https://github.com/dvasilen/Hive-XML-SerDe/issues/15
- I am don't think it supports the
i:nil="true"
- Mapping of column should match the column name and it's case sensitive.
column.xpath.Code
andcode
won't work. Also there is no corrosponding column forcolumn.xpath.ParentElement
So what you need to do?
- Upgrade your serde.
- replace
<EntityCode i:nil="true"/>
to<EntityCode/>
in your xml - Fix the code as mentioned below
Code
CREATE EXTERNAL TABLE temp.test_xml(
code String,
Entity array<struct<Entity:struct<EntityId:String,EntityCode:String>>>
)
ROW FORMAT SERDE 'com.ibm.spss.hive.serde2.xml.XmlSerDe'
WITH SERDEPROPERTIES
(
"column.xpath.code" = "/RootTag/Code/text()",
"column.xpath.Entity" = "/RootTag/ParentElement/Entity"
)
STORED AS
INPUTFORMAT 'com.ibm.spss.hive.serde2.xml.XmlInputFormat'
OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat'
LOCATION '/tmp/test_xml1/table/'
TBLPROPERTIES (
"xmlinput.start"="<RootTag",
"xmlinput.end"="</RootTag>");
There are few things.
- I think the root tag with namespace is only supported on version 1.5.0.3 or greater. check the following link https://github.com/dvasilen/Hive-XML-SerDe/issues/15
- I am don't think it supports the
i:nil="true"
- Mapping of column should match the column name and it's case sensitive.
column.xpath.Code
andcode
won't work. Also there is no corrosponding column forcolumn.xpath.ParentElement
So what you need to do?
- Upgrade your serde.
- replace
<EntityCode i:nil="true"/>
to<EntityCode/>
in your xml - Fix the code as mentioned below
Code
CREATE EXTERNAL TABLE temp.test_xml(
code String,
Entity array<struct<Entity:struct<EntityId:String,EntityCode:String>>>
)
ROW FORMAT SERDE 'com.ibm.spss.hive.serde2.xml.XmlSerDe'
WITH SERDEPROPERTIES
(
"column.xpath.code" = "/RootTag/Code/text()",
"column.xpath.Entity" = "/RootTag/ParentElement/Entity"
)
STORED AS
INPUTFORMAT 'com.ibm.spss.hive.serde2.xml.XmlInputFormat'
OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat'
LOCATION '/tmp/test_xml1/table/'
TBLPROPERTIES (
"xmlinput.start"="<RootTag",
"xmlinput.end"="</RootTag>");
answered Nov 19 at 20:18
Gaurang Shah
2,67311030
2,67311030
add a comment |
add a comment |
ilmar is a new contributor. Be nice, and check out our Code of Conduct.
ilmar is a new contributor. Be nice, and check out our Code of Conduct.
ilmar is a new contributor. Be nice, and check out our Code of Conduct.
ilmar is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53376332%2fhive-xml-serde-parsing-error-when-loading-xml-content%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown