This question already has an answer here:
Help ,I have two RDDs, i want to merge to one RDD.This is my code.
val us1 = sc.parallelize(Array(("3L"), ("7L"),("5L"),("2L")))
val us2 = sc.parallelize(Array(("432L"), ("7123L"),("513L"),("1312L")))
This question already has an answer here:
Help ,I have two RDDs, i want to merge to one RDD.This is my code.
val us1 = sc.parallelize(Array(("3L"), ("7L"),("5L"),("2L")))
val us2 = sc.parallelize(Array(("432L"), ("7123L"),("513L"),("1312L")))
You need the
RDD.union
These don't join on a key. Union doesn't really do anything itself, so it is low overhead. Note that the combined RDD will have all the partitions of the original RDDs, so you may want to coalesce after the union.API
Return the union of this RDD and another one.
def++ API
Return the union of this RDD and another one. Any identical elements will appear multiple times (use .distinct() to eliminate them).
def union API
Just use union:
Documentation is here
Shotcut in Scala is: