build the union of a list of rdds

Solutions on MaxInterview for build the union of a list of rdds by the best coders in the world

showing results for - "build the union of a list of rdds"
Riccardo
07 Nov 2018
1# Build the union of a list of RDDs
2
3path = os.path.join(tempdir, "union-text.txt")
4with open(path, "w") as testFile:
5  _ = testFile.write("Hello")
6textFile = sc.textFile(path)
7textFile.collect()
8# ['Hello']
9parallelized = sc.parallelize(["World!"])
10sorted(sc.union([textFile, parallelized]).collect())
11# ['Hello', 'World!']