Question on PIG quiz


4 Answer(s)


Hi Mahesh,

Try this

employee = LOAD 'emp.txt' using PigStorage(',')   as (name:chararray,age:int,salary:int,dept_id:int);
employee_phone= LOAD 'employee_phone.txt' using PigStorage(',')  as (dept_id:int, phone:chararray);
employee_john= FILTER employee by name == 'John';
dump employee_john;
employee_john_phone = JOIN employee_john by dept_id, employee by dept_id;


Hi Mahesh,

Try the Srini solution.

@Srini, thanks for the solution.

 


Question was from Quiz, which is finding phone number of John, I am not sure how we will get phone number without joining the "employee_phone", little cnfused.


Hi Mahesh,

employee = LOAD 'emp.txt' using PigStorage(',')   as (name:chararray,age:int,salary:int,dept_id:int);
employee_phone = LOAD 'employee_phone.txt' using PigStorage(',')  as (dept_id:int, phone:chararray);
employee_john = FILTER employee by name == 'John';
employee_john_phone = JOIN employee_john by dept_id, employee_phone by dept_id;
dump employee_john_phone;