Running Pig Scripts in Zeppelin

This section contains a sample of an Apache Pig script that you can run in your Apache Zeppelin notebook.

This example reads the contents of your password file and outputs the first field in the file: the user name.
  1. Using the shell interpreter, copy the password file to MapR Filesystem:

    To use POSIX shell commands like cp, you must have a MapR Filesystem mount point in your container. The example below assumes your mount point is /mapr and your cluster name is my.cluster.com:

    %sh
    cp /etc/passwd /mapr/my.cluster.com/user/mapruser1
    %sh
    hadoop fs -put /etc/passwd /user/mapruser1/
  2. Load the password file in Pig and output the first field in each line in the file:
    %pig
    A = load 'passwd' using PigStorage(':');  
    B = foreach A generate $0 as id;  
    dump B;

There are other examples of using Pig in the Zeppelin tutorial, including running Pig queries.