How to handle XML file in hive

寵の児 提交于 2019-12-11 18:39:02

问题


How to handle this XML file in hive, I want only USERNAME and PASSWORD in output

<?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>");

回答1:


Finally got output please refer https://community.hortonworks.com/articles/972/hive-and-xml-pasring.html



来源:https://stackoverflow.com/questions/50428444/how-to-handle-xml-file-in-hive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!