run and exec utility command difference in pig



0

Apache Pig Utility command gives two similar type of commands run and exec to execute pig script on grunt shell, I am looking the difference only run gives flexibility to developer some interaction with grunt shell where as exec just follow the instruction and don't accept any other input, my question is towards the use case where exactly it will be useful to use run over exec command.

Going through the apache pig documentation -http://pig.apache.org/docs/r0.17.0/cmds.html#run, where a very high level detail provided for these two command.

grunt> cat myscript.pig
b = ORDER a BY name;
c = LIMIT b 10;

grunt> a = LOAD 'student' AS (name, age, gpa);

grunt> run myscript.pig

grunt> d = LIMIT c 3;

grunt> DUMP d;
(alice,20,2.47)
(alice,27,1.95)
(alice,36,2.27)

grunt> cat myscript.pig
a = LOAD 'student' AS (name, age, gpa);
b = LIMIT a 3;
DUMP b;

grunt> exec myscript.pig
(alice,20,2.47)
(luke,18,4.00)
(holly,24,3.27)

3 Answer(s)


1

Hi Nitesh,

You are right, the major difference between the run and exec in pig is:
run - 1. every store triggers execution.
        2.The statements from the script are put into the command history and all the aliases defined in the script can be referenced in subsequent statements after the run command has completed

exec - 1. No store trigger execute.
         2. The statements from the script are available in command history. No reference is available after command.

When you have some task to execute on pig regulary, exec is preferrable. While when you have to execute certain commands before executing some final commands, you preferred run.

Hope this helps.

Thanks.


0

Thanks Abhijit this helped me to understand.


0

good