JuhiKude
JuhiKude

Reputation: 21

Extract XML data from Hive Table and Parse the data

I want to extract particular column values from a hive table. That column has XML data. How to parse through XML data and extract name and values from that particular XML column. Also I want to insert the extracted data into another Hive table.

Upvotes: 1

Views: 1196

Answers (1)

Ram Ghadiyaram
Ram Ghadiyaram

Reputation: 29175

Example :

select xpath ('<a><b id="1"><c/></b><b id="2"><c/></b></a>','/descendant::c/ancestor::b/@id') from t1 limit 1 ;
[1","2]

In both option you need to have Xpath expression knowledge.

If you want to insert extracted data in to another table then use create table as select xxx from xxxxx (Create Table As Select (CTAS))

Upvotes: 1

Related Questions