Hive 如何正确设置SerDe XML模式?

Hive 如何正确设置SerDe XML模式?,hive,hive-serde,Hive,Hive Serde,我得到了这个XML: <AssetCrossReferences Ordered="false"> <AssetCrossReference AssetID="F7961393-01" Type="Primary Image"/> <AssetCrossReference AssetID="M0504-01" Type="Vendor Logo"/> <AssetCrossReference AssetID="F7961393

我得到了这个XML:

  <AssetCrossReferences Ordered="false">
    <AssetCrossReference AssetID="F7961393-01" Type="Primary Image"/>
    <AssetCrossReference AssetID="M0504-01" Type="Vendor Logo"/>
    <AssetCrossReference AssetID="F7961393-02" Type="Colour Photograph"/>
 </AssetCrossReferences><Specification Ordered="true">
我如何做到这一点?

使用结构

create external table test 
(
   asset STRUCT<AssetID:STRING,Type:STRING>
)
ROW FORMAT SERDE 'com.ibm.spss.hive.serde2.xml.XmlSerDe'
with serdeproperties 
(
  "column.xpath.asset"="/AssetCrossReferences/AssetCrossReference"
)
stored as inputformat "com.ibm.spss.hive.serde2.xml.XmlInputFormat"
outputformat "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat"
location "file:///yourfilepath" 
tblproperties 
(
  "xmlinput.start"="<AssetCrossReferences",
  "xmlinput.end"="</AssetCrossReferences>"
);

发布你的脚本
create external table test 
(
   asset STRUCT<AssetID:STRING,Type:STRING>
)
ROW FORMAT SERDE 'com.ibm.spss.hive.serde2.xml.XmlSerDe'
with serdeproperties 
(
  "column.xpath.asset"="/AssetCrossReferences/AssetCrossReference"
)
stored as inputformat "com.ibm.spss.hive.serde2.xml.XmlInputFormat"
outputformat "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat"
location "file:///yourfilepath" 
tblproperties 
(
  "xmlinput.start"="<AssetCrossReferences",
  "xmlinput.end"="</AssetCrossReferences>"
);
select * from test;