pig tutorial - apache pig tutorial - Apache Pig Limit Operator - pig latin - apache pig - pig hadoop
What is Limit Operator in Apache Pig ?
- The LIMIT operator is used to get a limited number of tuples from a relation.
- This idea has come to mind visualizing the fact that " 'ddx' is an operator and derivative of a function is defined by 'Limit'".
- Well, the limit as x approaches something is an operator, such as limx→0.
- Truncates relation’s size
Syntax
Example
- Ensure that we have a file named wikitechy_employee_details.txt in the HDFS directory /pig_data/ as given below.
wikitechy_employee_details.txt
- You have loaded this file into Pig with the relation name wikitechy_employee_details as given below.
- Sort the relation in descending order based on the age of the employee and store it into another relation named limit_data using the ORDER BY operator as given below.
Verification
- Now verify the relation limit_data using the DUMP operator as shown below.
Output
- The following output, display the contents of the relation limit_data.