119
Apache Pig FOREACH Operator
The Apache Pig FOREACH operator generates data transformations based on columns of data. It is recommended to use FILTER operation to work with tuples of data.
Example of FOREACH Operator
In this example, we traverse the data of two columns exists in the given file.
Steps to execute FOREACH Operator
- Create a text file in your local machine and provide some values to it.
- Check the values written in the text files.
- Upload the text files on HDFS in the specific directory.
- Open the pig MapReduce run mode.
- Load the file that contains the data.
- Now, execute and verify the data.
- Let’s traverse the data of two columns.
Here, we got the desired output.
Next TopicGROUP Operator