113
Apache Pig COUNT Function
The Apache Pig COUNT function is used to count the number of elements in a bag. It requires a preceding GROUP ALL statement for global counts and a GROUP BY statement for group counts. It ignores the null values.
Example of COUNT Function
In this example, we count the tuples in the bag.
Steps to execute COUNT Function
- Create a text file in your local machine and insert the list of tuples.
- Check the tuples inserted 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 group the data on the basis of ‘a1’ field.
- Let’s return the count of given tuples.
Here, we got the desired output.
Next TopicIN Function