pig tutorial - apache pig tutorial - Apache Pig - MIN() Function - pig latin - apache pig - pig hadoop
What is MIN Function in Apache Pig ?
- The MIN() function used in Apache Pig is used to get the minimum value for a certain column in a single-column bag
- The MIN() function will ignore the NULL values while calculating the minimum values
- The MIN() function will requires a preceding GROUP ALL statement for the global minimums and a GROUP BY statement for the group minimums.
- The MIN() function return the minimum value which is given in a set of values and also will return the smallest value of the column which is given in the table.
- The MIN() function will return the smallest numeric value in a range of values and it will ignores the empty cells.
Learn apache-pig - apache-pig tutorial - - apache-pig examples - apache-pig programs
Syntax
Example
wikitechy_employee_details.txt
- We have loaded this file into Pig with the relation name wikitechy_employee_details which is given below:
Calculating the Minimum GPA
- We can group the relation wikitechy_employee_details by using the Group All operator, and we can store the result in the relation called employee_group_all which is given below
- It will produce a relation for calculating the minimum gpa as shown below.
- Now, we need to calculate the global minimum of GPA, of all the employees by using the MIN() function which is given below: