How to install apache PIG

                                     Installation of PIG:

1. untar file
tar -zxvf filename

2. go inside and export JAVA_HOME, HADOOP_HOME
export JAVA_HOME=/home/user/jdk1.7-45
export HADOOP_HOME=/home/user/hadoop-1.2.1

3. start pig
bin/pig

4. run commands on grunt prompt.

grunt> a = load '/first' as (id:int,name:chararray,city:chararray);
grunt> b = filter a by city == 'chennai';
grunt> c = foreach b generate name;
grunt> dump c;
grunt> store c into '/output';

grunt> b = foreach a generate id+1000;
grunt> dump b;

grunt> fs -copyFromLocal first /
grunt> a = load '/first' as (id:int,name:chararray,city:chararray);
grunt> b = foreach a generate city;
grunt> dump b;

grunt> ab = load '/infile.txt' using PigStorage(' ') as (first:chararray, last:chararray, age:int, dept:chararray);
grunt> b = FILTER ab BY last=='kumar';                                                                            
grunt> dump b;                                                                                                    


Comments

Popular posts from this blog

Setup Nginx as a Reverse Proxy for Thingsboard running on different port/server

How to auto re-launch a YARN Application Master on a failure.

Read JSON File in Cassandra