Support Questions
Find answers, ask questions, and share your expertise

Extract data from detail table using lookup table using Pig nested loop ?

New Contributor

I have 2 tables. One lookup & other detail one. I am having issues with looping with data from lookup table & extracting information from detail table. Appreciate any help.

Lookup table:

email

mobile

fax

Detail table

User1 email1 mobile1 fax1

User2 email2 mobile2 fax2

Output table:

email1

email2

mobile1

mobile2

fax1

fax2

3 REPLIES 3

Expert Contributor
@Nithin Sukumar

can you please provide the code you have written for it?

New Contributor

This is the code I have till now & it does not work :

contact_meth = load ‘lookup.txt’ using PigStorage(',') as (contact: string );

detail_tbl = load ‘detail.txt' using PigStorage(',') as (user:string, email:string, fax:string );

contact_meth_grpd = group contact_meth ALL ;

foreach contact_meth_grpd {

generate detail_tbl.contact }

My lookup table has list of columns that need to be extracted from the detail table. Thanks for the help !

Can't you use CROSS operator with FILTER operator for your use-case(or JOIN operator)?

grunt> cross_data = CROSS <detailed_table>, <lookup_table>;

grunt> joined_data = JOIN <detailed_table> BY email1, <lookup_table> BY email;

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.