In this article, we are going to discuss union,distinct,intersect,subtract transformations.
- Merging of two or more RDDs.
- rdd1.union(rdd2) which outputs a RDD which contains the data from both sources.
- If the input RDDs contain duplicate elements,resultant rdd from union operations also contain duplicate elements.
Q-1 We have one dataset students_marks.csv and other also dataset is also students marks dataset.How can we union these two datasets?
Distinct: If we require unique elements in RDD, distinct function can help here.
Q-2 Find out the distinct students names from students_marks.csv dataset?
Subtract: This transformation returns the RDD where elements exist in the first RDD not in the second RDD.
Q-3 Find out the students details that exist in the first RDD and not in the second RDD?
Intersection: The elements which exist in both the RDDs.It will return the unique elements,remove the duplicate, which exist in both the RDD.
Q-4 Find out the elements which exist in both the RDDs?
#Output #[‘Daniel,Computer Science,99,100’, ‘Daniel,Physics,98,100’, ‘Daniel,English,50,100’, ‘Daniel,Hindi,99,100’, ‘Daniel,Chemistry,98,100’, ‘Daniel,Maths,98,100’]