Home » Apache Pig UNION Operator

Apache Pig UNION Operator

by Online Tutorials Library

Apache Pig UNION Operator

The Apache Pig UNION operator is used to compute the union of two or more relations. It doesn’t maintain the order of tuples. It also doesn’t eliminate the duplicate tuples.

Example of UNION Operator

In this example, we compute the data of two relations.

Steps to execute UNION Operator

  • Create a text file in your local machine and write some values into it.

Apache Pig UNION Operator

  • Create another text file in your local machine and also write some values into it.

Apache Pig UNION Operator

  • Check the values written in both text files.

Apache Pig UNION Operator

  • Upload both 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 UNION Operator

  • Load the another file that contains the data.
  • Now, execute and verify the data.

Apache Pig UNION Operator

  • Let’s perform the union operation between both files.
  • Now, execute and verify the data.

Apache Pig UNION Operator

Here, we got the desired output.

Next TopicAVG Function

You may also like