Spark Intersection Function
In Spark, Intersection function returns a new dataset that contains the intersection of elements present in the different datasets. So, it returns only a single row. This function behaves just like the INTERSECT query in SQL.
Example of Intersection function
In this example, we intersect the elements of two datasets.
Here, we got the desired output.