Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Pig, mail # user - Split tuple with multiple fields to tuples with single field in Pig


Copy link to this message
-
Split tuple with multiple fields to tuples with single field in Pig
Dan Zhu 2013-07-25, 05:54
Hi pig-users,

I have tuples with varied length. I am trying to convert them to tuples with only one field (each field is a map).
Original data:
([symbol#HIG,security_type#EQUITY,foreign_entry_id#743094])
([symbol#PEW,security_type#EQUITY,foreign_entry_id#743084])
([symbol#AFFY,security_type#EQUITY,foreign_entry_id#5585],[symbol#RFG,security_type#ETF,foreign_entry_id#5586],[symbol#SCHW,security_type#EQUITY,foreign_entry_id#5587],[symbol#VWO,security_type#ETF,foreign_entry_id#5588])

I hope the output would be:
([symbol#HIG,security_type#EQUITY,foreign_entry_id#743094])
([symbol#PEW,security_type#EQUITY,foreign_entry_id#743084])
([symbol#AFFY,security_type#EQUITY,foreign_entry_id#5585])
([symbol#RFG,security_type#ETF,foreign_entry_id#5586])
 ([symbol#SCHW,security_type#EQUITY,foreign_entry_id#5587])
 ([symbol#VWO,security_type#ETF,foreign_entry_id#5588])

I have tried: FOREACH entryArray GENERATE FLATTEN(TOBAG(*));
It returns (only the first field of each tuple):
([symbol#HIG,security_type#EQUITY,foreign_entry_id#743094])
([symbol#PEW,security_type#EQUITY,foreign_entry_id#743084])
([symbol#AFFY,security_type#EQUITY,foreign_entry_id#5585])

Any suggestion would be very appreciated. Thanks!

Regards,

Dan