93
Apache Pig Group Operator
The Apache Pig GROUP operator is used to group the data in one or more relations. It groups the tuples that contain a similar group key. If the group key has more than one field, it treats as tuple otherwise it will be the same type as that of the group key. In a result, it provides a relation that contains one tuple per group.
Example of Group Operator
In this example, we group the given data on the basis of the last name.
Steps to execute Group Operator
- Create a text file in your local machine and write some text into it.
- Check the text written in the piginput2.txt file.
- Upload the piginput2.txt file on HDFS in the specific directory.
- Open the pig MapReduce run mode.
- Load the data into the bag.
- Now execute and verify the data.
- Let us group the data on the basis of l_name.
- Now, execute and verify the data.
Here, we got the desired output.
Next TopicLIMIT Operator