Home » Apache Pig FOREACH Operator

Apache Pig FOREACH Operator

by Online Tutorials Library

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.

Apache Pig FOREACH Operator

  • Check the values written in the text files.

Apache Pig FOREACH Operator

  • 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.

Apache Pig FOREACH Operator

  • Let’s traverse the data of two columns.

Apache Pig FOREACH Operator

Here, we got the desired output.

Next TopicGROUP Operator

You may also like