Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

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

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

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

Expert Contributor
@Nithin Sukumar

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

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

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 !

Highlighted

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

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;

Don't have an account?
Coming from Hortonworks? Activate your account here