如何在hive中处理xml文件

7bsow1i6  于 2021-06-01  发布在  Hadoop
关注(0)|答案(1)|浏览(392)

如何在配置单元中处理这个xml文件,我只需要在输出中输入用户名和密码

<?XML version=’1.0′ ?>
<DATA>
    <USER USERNAME="ABC" FIRSTNAME="RAJ" LASTNAME="KUMAR" PASSWORD="123" />
    <USER USERNAME="DEF" FIRSTNAME="VENKAT" LASTNAME="BALAJI" PASSWORD="123" />
</DATA>
CREATE TABLE user_xml(USERNAME string,PASSWORD string)
    ROW FORMAT SERDE 'com.ibm.spss.hive.serde2.xml.XmlSerDe'
    WITH SERDEPROPERTIES ( 
        "column.xpath.USERNAME"="/DATA/USER/USERNAME/text()",
        "column.xpath.PASSWORD"="/DATA/USER/PASSWORD/text()"
    ) STORED AS
        INPUTFORMAT 'com.ibm.spss.hive.serde2.xml.XmlInputFormat'
        OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat'
        TBLPROPERTIES ("xmlinput.start"="<DATA","xmlinput.end"="</DATA>");
krugob8w

krugob8w1#

最终得到输出请参考https://community.hortonworks.com/articles/972/hive-and-xml-pasring.html

相关问题