111
Apache Pig SUM Function
The Apache Pig SUM function is used to find the sum of the numeric values in a single-column bag. It requires a preceding GROUP ALL statement for global sums and a GROUP BY statement for group sums. It ignores the null values.
Example of SUM Function
In this example, we compute the sum of given numeric values.
Steps to execute SUM 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 sum of given numeric values.
Here, we got the desired output.
Next TopicTOKENIZE Function