88
Apache Pig AVG Function
The Apache Pig AVG function is used to find the average of given numeric values in a single-column bag. It requires a preceding GROUP ALL statement for global averages and a GROUP BY statement for group averages. However, it ignores the NULL values.
Example of AVG Function
In this example, we will compute the average of given numeric values.
Steps to execute AVG 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 average of given numeric values.
Here, we got the desired output.
Next TopicCONCAT Function