Home » Apache Pig MAX Function

Apache Pig MAX Function

by Online Tutorials Library

Apache Pig MAX Function

The Apache Pig MAX function is used to find out the maximum of the numeric values or chararrays in a single-column bag. It requires a preceding GROUP ALL statement for global maximums and a GROUP BY statement for group maximums. However, it ignores the NULL values.

Syntax

Here,

exp – It is an expression with data types like chararray, int, float, long, etc.

Example of MAX Function

In this example, we will find out the maximum of the given values.

Steps to execute MAX Function

  • Create a text file in your local machine and insert the list of tuples.

Apache Pig MAX Function

  • Check the tuples inserted in the text files.

Apache Pig MAX 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 MAX Function

  • Let’s group the data on the basis of ‘a1’ field.

Apache Pig MAX Function

  • Let’s return the maximum of given numeric values.

Apache Pig MAX Function

Here, we got the desired output.

Next TopicMIN Function

You may also like