Search This Blog

Sunday, 2 March 2025

BIGLAB-1

 first create data file emp111.txt in ur LFS

2. MOVE to HDFS

3. OPen vi editor type Pig Script


4. vi pig1.pig


bag1= load 'emp111.txt' using PigStorage(',')as (eno:int,ename:chararray,sal:int);

bag2= filter bag1 by sal > 34000;

store bag2 into 'pigoutput11' using PigStorage(',');


5. execute script

 pig pig1.pig


-------------------------------------------------

avg salary group by clause

-----------------------------------------


bag1= load 'emp11.txt' using PigStorage(',')as (eno:int,ename:chararray,sal:int,dname:chararray);

bag2= group bag1 by dname;

bag3= foreach bag2 generate bag1.dname, AVG(bag1.sal);

store bag4 into 'avgop2' using PigStorage(',');

---------------------------------------------------------------------

A= load 'emp11.txt' using PigStorage(',')as (eno:int,ename:chararray,sal:int,dname:chararray);

B= group A by dname;

C= foreach B generate SUM(A.sal);

dump C;

-----------------------------------------------------------------------------------

bag1= load 'emp22.txt' using PigStorage(',')as (eno:int,ename:chararray,sal:int,dname:chararray);

bag2= group bag1 all;

bag3= foreach bag2 generate  SUM(bag1.sal);

store bag3 into 'sumop' using PigStorage(',');

---------------------------------------------------------------------
myfile= load 'wc.txt' as line:chararray;
words= foreach myfile generate flatten(TOKENIZE(line)) as word;
grpd= group words by word;
ctnd= foreach grpd generate group, COUNT(words) as count;
ordered= order ctnd by count desc;
dump ordered;
------------------------------------------------------


No comments:

Post a Comment

Hadoop Analytics

BIGLAB-HABSE-1

  Create an HBase Table for Orders Let’s create a table named orders to store the order data. The table will have the following columns: Ro...