Spark Union FunctionIn Spark, Union function returns a new dataset that contains the combination of elements present in the different datasets. Example of Union functionIn this example, we combine the elements of two datasets. - To open the spark in Scala mode, follow the below command.
- Create an RDD using parallelized collection.
- Now, we can read the generated result by using the following command.
- Create another RDD using parallelized collection.
- Now, we can read the generated result by using the following command.
- Apply union() function to return the union of the elements.
- Now, we can read the generated result by using the following command.
Here, we got the desired output.
|