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.


Here’s the syntax of the UNION operator.


Let’s take two files namely student_data1.txt and student_data2.txt in the /pig_data/ directory of HDFS as mentioned below.
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.


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


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

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

Apache Pig Topics