Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

How to extact two fields( more than one) in pig nested foreach

avatar
Expert Contributor

Hi All,

According to my requirement i need script like following

A = load '/bsuresh/sample' USING PigStorage(',') as (id,name,sal,deptid);
 B = GROUP A by deptid;
 C = foreach B {
         D = A.name,A.sal;--two fields
	 E = DISTINCT D;
         generate group,COUNT(E);
};

In relation 'D', i am extracting two fields.Where exactly i am facing error.

If i chnaged the script like,which is working fine.

C = foreach B {
         D = A.name; --one filed
 	 E = DISTINCT D;
        generate group,COUNT(E);
};

But i need count based on distinct of two columns .Can any one help me??

1 ACCEPTED SOLUTION

avatar
Master Mentor
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login
3 REPLIES 3

avatar
Master Mentor
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login

avatar
Expert Contributor

Yeah ...@Artem Ervits i got your point.simple but logical.

avatar
Master Mentor

@Suresh Bonam let me know if that works for you and close the thread :).