Database Reference
In-Depth Information
Figure 6-8
.
Output of the FILTER command
FOREACH
Use this function to iterate over result bags and transform into output or intermediate
results (see
Figure 6-9
).
similar_result = FOREACH pipe_input GENERATE(*);
result_with_screen_name_only=FOREACH pipe_input GENERATE
screen_name;
dump result_with_screen_name_only;
Figure 6-9
.
Running FOREACH to generate intermediate results
TOTUPLE
TOTUPLE is a function to generate tuples. For example we can use
TOTUPLE
to gen-
erate a tuple of column name and value as shown in
Figure 6-10
.
screen_tuple = FOREACH pipe_input GENERATE
TOTUPLE('screen_name',screen_name);
Figure 6-10
.
Depicts generated tuple having screen_name as apress_team
Previously, we discussed a few basic Pig Latin commands. Let's explore Apache
Pig with more sample exercises. For all the exercises in this chapter we will be refer-
ring to the
tweets
file which contains tweets about
apress.
You can download the