Javatpoint Logo
Javatpoint Logo

Spark Union Function

In Spark, Union function returns a new dataset that contains the combination of elements present in the different datasets.

Example of Union function

In this example, we combine the elements of two datasets.

  • To open the spark in Scala mode, follow the below command.
Spark Union Function
  • Create an RDD using parallelized collection.
  • Now, we can read the generated result by using the following command.
Spark Union Function
  • Create another RDD using parallelized collection.
  • Now, we can read the generated result by using the following command.
Spark Union Function
  • Apply union() function to return the union of the elements.
  • Now, we can read the generated result by using the following command.
Spark Union Function

Here, we got the desired output.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback

  • Send your Feedback to feedback@javatpoint.com

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA