Loading xml data into hive table :org.apache.hadoop.hive.ql.metadata.HiveException

后端 未结 6 2224
借酒劲吻你
借酒劲吻你 2021-02-06 14:48

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

6条回答
  •  灰色年华
    2021-02-06 15:08

    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

    11Computer4444Fantasy5
    

    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
    

提交回复
热议问题