- Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathread_write_demo.py
20 lines (15 loc) · 743 Bytes
/
read_write_demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
fromtypingimportDict
frompyspark.sqlimportSparkSession
importread_demo
importwrite_demo
fromschemasimportmovie_schema
defread_write_demo(spark: SparkSession, opts: Dict[str, str]):
print("-----------------------")
print("--- READ-WRITE DEMO ---")
print("-----------------------")
print("Reading 'movies' collection and writing 'actionMovies' collection...")
action_movies_df=read_demo.read_collection(spark, "movies", opts, movie_schema)\
.select("_key", "title", "releaseDate", "runtime", "description")\
.filter("genre = 'Action'")
write_demo.save_df(action_movies_df.to_pandas_on_spark(), "actionMovies", opts)
print("You can now view the actionMovies collection in ArangoDB!")