Data science Software Course Training in Ameerpet Hyderabad

Data science Software Course Training in Ameerpet Hyderabad

Saturday, 23 July 2016

Pig Lab10 : Quarterly sales Report and comparing sales with Previous Quarter. Cross .

grunt> raw = load 'piglab/sales'
>>     using PigStorage(',')
>>     as (dt:chararray, amt:int);
grunt> msales = foreach raw generate  
>>      SUBSTRING(dt,0,2)  as m, amt ; 
grunt> describe msales;
msales: {m: chararray,amt: int}
grunt> msales = foreach msales generate
>>         (int)m, amt;
grunt> describe msales;                
msales: {m: int,amt: int}
grunt> dump msales;

grunt> qsales = foreach msales generate
>>       (m<4 ? 1:
>>         (m<7 ? 2:
>>           (m<10 ? 3:4))) as q, amt ;
grunt> dump qsales

grunt> qsales = foreach msales generate
>>       (m<4 ? 1:
>>         (m<7 ? 2:
>>           (m<10 ? 3:4))) as q, amt ;
grunt> dump qsales

grunt> rep2 = foreach rep generate *;
grunt> cr = cross rep, rep2;
grunt> describe cr
cr: {rep::q: int,rep::tot: long,rep2::q: int,rep2::tot: long}
grunt> cr = foreach cr generate 
>>     rep::q as q1, rep2::q as q2,
>>     rep::tot as tot1, rep2::tot as tot2;

grunt> describe cr;
cr: {q1: int,q2: int,tot1: long,tot2: long}
grunt> dump cr;

grunt> fltd = filter cr by ((q1-q2)==1);
grunt> dump fltd;

grunt> res = foreach fltd generate *,
>>        ((tot1-tot2)*100)/tot2 as pgrowth;
grunt> dump res

(3,2,70000,355000,-80)
(2,1,355000,140000,153)
(4,3,290000,70000,314)

_________________________________





3 comments:

  1. please any one knows how to set up Hadoop i need your help seriously,
    whatsAPP me 9701950514

    ReplyDelete
  2. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
    Big Data Hadoop Training in electronic city

    ReplyDelete