pig tutorial - apache pig tutorial - Apache Pig - Order By - pig latin - apache pig - pig hadoop
What is ORDER BY operator in Apache Pig ?
- The ORDER BY operator is used to display the contents of a relation in a sorted order based on one or more fields. (or) ORDER BY operator is used to sort the data in ascending or descending order, based on one or more columns.
- Some data sort the results in an ascending order by default.
- Sorts relations by a specific criteria
- Ensure that we have a file named wikitechy_employee_details.txt in the HDFS directory /pig_data/ as given below.
- And we have loaded this file into Pig with the relation name wikitechy_student_details as shown below.
- Here sort the relation in a descending order based on the age of the employee and store it into another relation named order_by_data using the ORDER BY operator as given below.
- Now verify the relation order_by_data using the DUMP operator as given below.
- The following output, display the contents of the relation order_by_data.