我正在使用Hadoop Hive并尝试处理XML文件。该文件是这样的:Hadoop Hive XPath只返回数组的一部分
<asds4_0:SASDS>
<stl15:GetRS>
<stl15:RS>
<stl15:ORES>
<stl15:ORE>
<stl15:AccF>
<stl15:Transaction>
<stl15:Status>Hold</stl15:Status>
</stl15:Transaction>
</stl15:AccF>
</stl15:ORE>
<stl15:ORE>
<stl15:AccF>
<stl15:Transaction>
<stl15:Status>Active</stl15:Status>
</stl15:Transaction>
</stl15:AccF>
</stl15:ORE>
</stl15:ORES>
</stl15:RS>
</stl15:GetRS>
</asds4_0:SASDS>
中的XPath我使用检索状态为:
SELECT
Status
FROM scenario1
LATERAL VIEW explode(xpath(cast(body as string),"//*[local-name()='SASDS']//*[local-name()='GetRS']//*[local-name()='RS']//*[local-name()='ORES']//*[local-name()='ORE']//*[local-name()='AccF']//*[local-name()='Transaction']//*[local-name()='Status']/text()")) adTable as Status
这个XPath返回二者的状态主动和保持。问题是我只想检索Active状态。 我尝试使用这样的[[local-name()='Status'] ='Active'](就像这里显示的https://www.w3schools.com/xml/xpath_syntax.asp)我仍然得到两个记录保持和活动。
我不想在sql中使用WHERE Status ='Active',因为当我将它与其他字段组合时,它不会返回所需的行。
强制性的评论:https://meta.stackoverflow.com/questions/280478 /为什么 - 不W3Schools的-COM – dirkk