Home » Apache Pig LIMIT Operator

Apache Pig LIMIT Operator

by Online Tutorials Library

Apache Pig LIMIT Operator

The Apache Pig LIMIT operator is used to limit the number of output tuples. However, if you specify the limit of output tuples equal to or more than the number of tuples exists, all the tuples in the relation are returned.

Example of LIMIT Operator

In this example, we return only two tuples from all the tuples in the relation.

Steps to execute LIMIT Operator

  • Create a text file in your local machine and insert the list of tuples.

Apache Pig LIMIT Operator

  • Check the tuples inserted in the text files.

Apache Pig LIMIT Operator

  • 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.

Apache Pig LIMIT Operator

  • Let’s return the first two tuples.

Apache Pig LIMIT Operator

Here, we got the desired output.

Next TopicORDER BY Operator

You may also like