118
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.
- 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 maximum of given numeric values.
Here, we got the desired output.
Next TopicMIN Function