Chapter 3. Grunt
Grunt[4] is Pig’s interactive shell. It enables users to enter Pig Latin interactively and provides a shell for users to interact with HDFS.
To enter Grunt, invoke Pig with no script or command to run. Typing:
pig -x local
will result in the prompt:
grunt>This gives you a Grunt shell to interact with your
local filesystem. If you omit the -x local and have a
cluster configuration set in PIG_CLASSPATH, this will put you
in a Grunt shell that will interact with HDFS on your cluster.
As you would expect with a shell, Grunt provides
command-line history and editing, as well as Tab completion. It does not provide filename completion via
the Tab key. That is, if you type kil and then press the
Tab key, it will complete the command as kill. But if you
have a file foo in your local directory
and type ls fo, and then hit Tab, it will not complete it
as ls foo. This is because the response time from HDFS to
connect and find whether the file exists is too slow to be useful.
Although Grunt is a useful shell, remember that it is not a full-featured shell. It does not provide a number of commands found in standard Unix shells, such as pipes, redirection, and background execution.
To exit Grunt you can type quit
or enter Ctrl-D.
Entering Pig Latin Scripts in Grunt
One of the main uses of Grunt is to enter Pig Latin in an interactive session. This can be particularly useful for quickly sampling your data and for prototyping new Pig Latin scripts.
You can enter Pig Latin directly into Grunt. ...