Pig actions as transformations
Thursday, February 24, 2011
1:33 PM
Pig actions can either 
filter and order records (without changing the schema): 
DISTINCT, FILTER, LIMIT, ORDER...
or transform data schemas: 
FOREACH-GENERATE, GROUP-BY, JOIN-BY …
Reading a schema: remember that
(…) is a tuple
{…} is a bag
{(…)} is a bag of tuples
a:int is an element named a that is an int. 
So the schema 
foo: {a:int, b:chararray} 
refers to an alias foo that generates a tuple space (outer bag) of tuples where the first term is an int and the second term is a chararray (string). while the schema
bar: {a:int, b:{c:int, d:chararray}} 
refers to an alias bar that generates a tuple space (outer bag) of tuples, where each tuple has a first term that is an int and a second term that is a bag of two-tuples.
You can print schemas with the DESCRIBE command.