I\'m trying to load XML data into Hive but I\'m getting an error :
java.lang.RuntimeException: org.apache.hadoop.hive.ql.metadata.HiveException: Hive Runt
Reason for error :
1) case-1 : (your case) - xml content is being fed to hive as line by line.
input xml:
11
Computer
44
44
Fantasy
5
check in hive :
select count(*) from xmltable; // return 13 rows - means each line in individual row with col xmldata
Reason for err :
XML is being read as 13 pieces not at unified. so invalid XML
2) case-2 : xml content should be fed to hive as singleString - XpathUDFs works refer syntax : All functions follow the form: xpath_(xml_string, xpath_expression_string).* source
input.xml
11 Computer 44 44 Fantasy 5
check in hive:
select count(*) from xmltable; // returns 1 row - XML is properly read as complete XML.
Means :
xmldata = ......
then apply your xpathUDF like this
select xpath(xmldata, 'xpath_expression_string' ) from xmltable