Apache Pig Union Operator - Apache Pig

What is UNION operator in Apache Pig?

The UNION operator of Pig Latin is used to combine the content of two relations. It is must to have identical columns and domains to perform UNION operation on two relations.

Syntax

Here’s the syntax of the UNION operator.

Example

Let’s take two files namely student_data1.txt and student_data2.txt in the /pig_data/ directory of HDFS as mentioned below.
Student_data1.txt
Student_data2.txt
Now load these two files into Pig with the relations student1 and student2 as shown below.
Let’s combine both the contents of these two relations with the UNION operator as mentioned below.

Verification

Now, verify the relation student using the DUMP operator as mentioned below.

Output

Then it will deliver the below output, displaying the contents of the relation student.

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

Apache Pig Topics