Options
- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Apache Pig scrips alias name usage
Labels:
- Labels:
-
Apache Pig
New Contributor
Created ‎11-09-2017 12:13 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 linegrouped = group B by word
and the role of alias over here.
1 REPLY 1
Guru
Created ‎02-09-2018 07:02 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A = load 'Desktop/wordcount.txt'as(col1:chararray);
B = foreach A generate flatten(TOKENIZE(col1))as (word:chararray);
C = group B by word;
cnt = foreach C generate flatten(group), COUNT(B.word);
dump cnt;
