Hi Nivetha, I don't know if I understood it correctly, but I think you can just use FLATTEN to "flatten" your bag.
It would become something like: A = ... B = FOREACH A GENERATE FLATTEN(YourUDF(input)) AS (description, name, no, trans_no); and then you can access your data normally by just using the name you gave in the flatten output schema: Ex.: C = FOREACH B GENERATE trans_no, no, name, description; I hope this helps :) Rodrigo Ferreira. 2014-07-18 11:33 GMT+02:00 Nivetha K <nivethak3...@gmail.com>: > Hi, > > I am working with Pig. How to parse XML with nested tags using UDF.I > tried with UDF and used List<Tuple> as the return type of the UDF while > compiling i get Unexpected data type java.util.ArrayList found in stream. > Note only standard Pig type is supported when you output from UDF/LoadFunc. > So I used bag as the return type , now I am having problem with retrieving > the fields using Pig . > > My bag having the tuples where all the tuples having same > schema I don't know how to retrive those values. > > XML: > > > > <transaction><trans><trans_no>123</trans_no><pkid><pk1><no>10</no><name>nivetha</name></pk1><pk1><no>20</no><name>anu</name></pk1><pk1><no>30</no><name>anitha</name></pk1></pkid><description>Some > > text</description></trans><trans><trans_no>124</trans_no><pkid><pk1><no>90</no><name>nivetha1</name></pk1><pk1><no>80</no><name>anu1</name></pk1><pk1><no>70</no><name>anitha1</name></pk1></pkid><description>Some > text</description></trans></transaction> > > My UDF Output: > > ({(Some text,nivetha,10,123),(Some text,anu,20,123),(Some > text,anitha,30,123)}) > ({(Some text,nivetha1,90,124),(Some text,anu1,80,124),(Some > text,anitha1,70,124)}) > > > > regards, > > Nivetha >