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.

Syntax

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

Example

Assume we have a file named employee_details.txt in the HDFS directory /pig_data/, with the following content.
employee_details.txt
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.

Verification

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