Apache Pig - Bag&Tuple-TOBAG() - Apache Pig

What is TOBAG()?

The TOBAG() function of Pig Latin converts one or more expressions to individual tuples. And these tuples are placed in a bag.


Given below is the syntax of the TOBAG() function.


Assume we have a file named employee_details.txt in the HDFS directory /pig_data/, with the following content.
We have loaded this file into Pig with the relation name emp_data as shown below.
Let us now convert the id, name, age and city, of each employee (record) into a tuple as shown below.


You can verify the contents of the tobag relation using the Dump operator as shown below.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Apache Pig Topics