Three datasets join in Pig
------------------------salrec = load '/home/hadoop/Desktop/Sales.csv' using PigStorage(',') AS
(custid:long, prod_id:long, qty_pur:int, pur_date:datetime, sale_id:long);
custrec = load '/home/hadoop/Desktop/Customer.csv' using PigStorage(',') AS (fn:chararray, ln:chararray, status:chararray, ph:chararray, custid1:long, add:chararray);
pd_rec = load '/home/hadoop/Desktop/Product.csv' using PigStorage(',') AS (pdname:chararray, pddesc:chararray, pdcat:chararray, pdgty:long, pdid:long, pkwith:chararray);
slrec_pdrec = join salrec by prod_id full, pd_rec by pdid ;
crs_rec = join custrec by custid1,slrec_pdrec by custid ;
STORE crs_rec into '/home/hadoop/Desktop/pigout1' using PigStorage();
sample output
7 98243 1 2012-01-24T00:00:00.000+05:30 34842 Allen Jaskobec A 416-299-0202 7 Bigcity|12345
11 77623 2 2012-01-24T00:00:00.000+05:30 34843 John Jarkin A 416-622-0991 11 Bigcity|12345
19 88734 7 2012-01-24T00:00:00.000+05:30 34857 Hubert Banhent A 416-526-8888 19 Bigcity|12345
24 45641 5 2012-01-24T00:00:00.000+05:30 34856 Roger Getnet I 416-309-9982 24 Bigcity|12345
47 92387 1 2012-01-24T00:00:00.000+05:30 34854 Cliff Mello A 416-210-9997 47 Bigcity|12345
64 98243 1 2012-01-09T00:00:00.000+05:30 34826 Mello Reynolds A 905-245-4431 64 Mediumcity|67890
64 77624 17 2012-01-09T00:00:00.000+05:30 34833 Mello Reynolds A 905-245-4431 64 Mediumcity|67890
64 92387 4 2012-01-24T00:00:00.000+05:30 34847 Mello Reynolds A 905-245-4431 64 Mediumcity|67890
97 99202 1 2012-01-09T00:00:00.000+05:30 34840 Ilyenko Merdec A 416-293-8771 97 Bigcity|12345
102 98243 1 2012-01-24T00:00:00.000+05:30 34851 Elizabeth Ilyenko A 416-354-2778 102 Bigcity|12345
128 88734 4 2012-01-09T00:00:00.000+05:30 34839 Melcic Lexter A 416-823-4443 128 Bigcity|12345
176 77623 1 2012-01-09T00:00:00.000+05:30 34838 Merdec Vickers I 416-298-0908 176 Bigcity|12345
227 77623 1 2012-01-24T00:00:00.000+05:30 34852 Arthur Panelo A 905-276-9987 227 Mediumcity|67890
322 99202 6 2012-01-09T00:00:00.000+05:30 34841 Roscoe Morris A 905-455-3221 322 Mediumcity|67890
No comments:
Post a Comment