title: org.apache.hadoop.hive.ql.metadata.HiveException: Hive Runtime Error while processing row {"xmldata":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"}
body: <p>I am trying to load data which is in xml format, into a hive table:-</p>
  
  <p>My XML file looks like this-</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;catalog&gt;
  &lt;book&gt;
    &lt;id&gt;11&lt;/id&gt;
    &lt;genre&gt;Computer&lt;/genre&gt;
    &lt;price&gt;44&lt;/price&gt;
  &lt;/book&gt;
  &lt;book&gt;
    &lt;id&gt;44&lt;/id&gt;
    &lt;genre&gt;Fantasy&lt;/genre&gt;
    &lt;price&gt;5&lt;/price&gt;
  &lt;/book&gt;
  &lt;/catalog&gt;
  </code></pre>
  
  <p>Firstly I have loaded the xml data into a managed table and then I am using the xpath UDF function to parse the XML data and load actual values in my main table.Following are hive queries I am trying with:-</p>
  
  <pre><code>create table XmlSample(xmlData string);
  
  
  load data inpath 'EmployeeDetails.xml' into table XmlSample;
  
  create table xpath_table(id int,genre string,price string);
  
  Insert overwrite table xpath_table select xpath_int(xmlData, '/catalog/book/id/text()'), xpath_string(xmlData, '/catalog/book/genre/text()'), xpath_string(xmlData, '/catalog/book/price/text()') from XmlSample;
  </code></pre>
  
  <p>But I am getting exception-</p>
  
  <pre><code>    java.lang.RuntimeException: org.apache.hadoop.hive.ql.metadata.HiveException: Hive Runtime Error while processing row {"xmldata":"&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;"}
      at org.apache.hadoop.hive.ql.exec.mr.ExecMapper.map(ExecMapper.java:175)
      at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:50)
      at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:430)
      at org.apache.hadoop.mapred.MapTask.run(MapTask.java:366)
      at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
      at java.security.AccessController.doPrivileged(Native Method)
      at javax.security.auth.Subject.doAs(Subject.java:415)
      at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1190)
      at org.apache.hadoop.mapred.Child.main(Child.java:249)
  Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: Hive Runtime Error while processing row {"xmldata":"&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;"}
      at org.apache.hadoop.hive.ql.exec.MapOperator.process(MapOperator.java:544)
      at org.apache.hadoop.hive.ql.exec.mr.ExecMapper.map(ExecMapper.java:157)
      ... 8 more
  Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: Unable to execute method public int org.apache.hadoop.hive.ql.udf.xml.UDFXPathInteger.evaluate(java.lang.String,java.lang.String)  on object org.apache.hadoop.hive.ql.udf.xml.UDFXPathInteger@37fd3f of class org.apache.hadoop.hive.ql.udf.xml.UDFXPathInteger with arguments {&lt;?xml version="1.0" encoding="UTF-8"?&gt;:java.lang.String, /catalog/book/id/text():java.lang.String} of size 2
      at org.apache.hadoop.hive.ql.exec.FunctionRegistry.invoke(FunctionRegistry.java:1030)
      at org.apache.hadoop.hive.ql.udf.generic.GenericUDFBridge.evaluate(GenericUDFBridge.java:181)
      at org.apache.hadoop.hive.ql.exec.ExprNodeGenericFuncEvaluator._evaluate(ExprNodeGenericFuncEvaluator.java:166)
      at org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator.evaluate(ExprNodeEvaluator.java:77)
      at org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator.evaluate(ExprNodeEvaluator.java:65)
      at org.apache.hadoop.hive.ql.exec.SelectOperator.processOp(SelectOperator.java:80)
      at org.apache.hadoop.hive.ql.exec.Operator.process(Operator.java:504)
      at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:842)
      at org.apache.hadoop.hive.ql.exec.TableScanOperator.processOp(TableScanOperator.java:91)
      at org.apache.hadoop.hive.ql.exec.Operator.process(Operator.java:504)
      at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:842)
      at org.apache.hadoop.hive.ql.exec.MapOperator.process(MapOperator.java:534)
      ... 9 more
  Caused by: java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at org.apache.hadoop.hive.ql.exec.FunctionRegistry.invoke(FunctionRegistry.java:1006)
      ... 20 more
  Caused by: java.lang.RuntimeException: Invalid expression '/catalog/book/id/text()'
      at org.apache.hadoop.hive.ql.udf.xml.UDFXPathUtil.eval(UDFXPathUtil.java:74)
      at org.apache.hadoop.hive.ql.udf.xml.UDFXPathUtil.evalNumber(UDFXPathUtil.java:87)
      at org.apache.hadoop.hive.ql.udf.xml.UDFXPathInteger.evaluate(UDFXPathInteger.java:35)
  </code></pre>
  
  <p>Can someone please advise how can I avoid these exceptions.</p>