Javatpoint Logo
Javatpoint Logo

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

Here, we got the desired output.

Next TopicTOKENIZE Function




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA