Javatpoint Logo
Javatpoint Logo

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.
Apache Pig AVG Function
  • Check the tuples inserted in the text files.
Apache Pig AVG Function
  • 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 AVG Function
  • Let's group the data on the basis of 'a1' field.
Apache Pig AVG Function
  • Let's return the average of given numeric values.
Apache Pig AVG Function

Here, we got the desired output.

Next TopicCONCAT Function





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA