/    /  Pig Latin – Loading and Storing

Pig Latin – Loading and Storing:

LOAD:

A LOAD statement reads data from the file system.

In this example Pig will validate, but not execute, the LOAD

A = LOAD 'student' USING PigStorage() AS (name:chararray, age:int, gpa:float);

Here Pig will read all the files present in the hdfs ‘/data’ directory having ‘,’ as the delimiter.

A = LOAD '/data' USING PigStorage(‘,’) AS (name:chararray, age:int, gpa:float);

In this example, Pig will validate and then execute the LOAD, DUMP statements.

A = LOAD 'student' USING PigStorage() AS (name:chararray, age:int, gpa:float);

DUMP B;
STORE:

Stores or saves results to the file system.

Use the STORE operator to run (execute) Pig Latin statements and save (persist) results to the file system. Use STORE for production scripts and batch mode processing.

STORE A INTO 'myoutput' USING PigStorage ('*');

STORE B INTO 'myoutput' using PigStorage(',');

 

DUMP:

Dumps or displays results to screen.

DUMP A;