I am referring one basic pig script to count number of words as follows:
A = load 'Desktop/wordcount.txt' as (col1:chararray);
B = foreach A generate flatten(TOKENIZE(col1)) as word;
grouped = group B by word;
cnt = foreach grouped generate B, COUNT(B);
dump cnt;
And using wordcount.txt file with contents as below:
This is pig test
This is pig test
word
in the above code is used as an alias for foreach A generate flatten(TOKENIZE(col1))
.
Not able to exactly understand the use of below line
grouped = group B by word
and the role of alias over here.