...

Big Data - Apache Pig

Back to Course

Lesson Description


Lession - #471 Apache pig LIMIT Operator


The Apache Pig LIMIT operator is utilized to restrict the quantity of result tuples. However, assuming you specify the limit of result tuples equivalent to or more than the number of tuples exists, all the tuples in the relation are returned.

The syntax of LIMIT operator is shown below:


 
 grunt> Result = LIMIT Relation_name required number of tuples;
 


Example

Assume that we have a file named student_details.txt in the HDFS directory /pig_data/ as shown below.

1 aaa 74385738 delhi
2 bbb 76349948 mumbai
3 ddd 87493589 pune
4 ggg 74824727 goa
5 hhh 74843847 pune
6 uuu 76347242 delhi


Writing LIMIT Operator


grunt> limit_data = LIMIT student_details 3; 
 
Output



1 aaa 74385738 delhi
2 bbb 76349948 mumbai
3 ddd 87493589 pune