forked from jleetutorial/python-spark-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJoinOperations.py
More file actions
20 lines (14 loc) · 764 Bytes
/
JoinOperations.py
File metadata and controls
20 lines (14 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from pyspark import SparkContext, SparkConf
if __name__ == "__main__":
conf = SparkConf().setAppName("JoinOperations").setMaster("local[1]")
sc = SparkContext(conf = conf)
ages = sc.parallelize([("Tom", 29), ("John", 22)])
addresses = sc.parallelize([("James", "USA"), ("John", "UK")])
join = ages.join(addresses)
join.saveAsTextFile("out/age_address_join.text")
leftOuterJoin = ages.leftOuterJoin(addresses)
leftOuterJoin.saveAsTextFile("out/age_address_left_out_join.text")
rightOuterJoin = ages.rightOuterJoin(addresses)
rightOuterJoin.saveAsTextFile("out/age_address_right_out_join.text")
fullOuterJoin = ages.fullOuterJoin(addresses)
fullOuterJoin.saveAsTextFile("out/age_address_full_out_join.text")