Here ,we will be running Apache Pig Sample scripts using grunts. Don't worry if you will not understand entire syntax, it is to just see the power of Apache Pig.
Step 1 : Start Grunt shell.
Step 5 : Now do the wordcount.
Now here we can see that, no need to wait for job to finish, we can check the results in between. After each step using DUMP statement we can check that our script is correct. As we will move ahead, we will be keep writing complex applications and understand the concepts.
Pig Scripts can have branching like multiple data inputs are joined (De-normalizing) and data splitting etc.
Grunt : It is a shell, where we have been writing our Pig scripts. Generally production code will be written in a separate file. But while writing we want to test our scripts with test data, hence we will be using Grunt shell for prototyping our script.
Dump and Store : Pig Latin will not execute scripts until it sees Dump or Store command , as we have done in our example.
Killing Job Inside Grunt shell : By using kill command , we can kill the MapReduce jobs. Usually as soon as you submit your pig scripts it will print job_id as well. And you can use kill command and job_id together to kill the job as below.
exec command : Inside Grunt shell , you can use exec command to run Pig script.
run command : Inside Grunt shell , you can use run command to run Pig script.
Difference between run and exec : run command runs the Pig Latin script in the same shell in which run command is executed.Hence, all the aliases defined inside the scripts will be available in same shell. But this is not the case with the exec command.