Created
June 11, 2020 10:21
-
-
Save kovid-r/f14f379ffc51af91905022a91d6529b3 to your computer and use it in GitHub Desktop.
Writing Files PySpark Cheatsheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Write file to disk in parquet format partitioned by year - overwrite any existing file | |
df.write.partitionBy('year').format('parquet').mode('overwrite').save(parquet_file_path) | |
# Write file to disk in parquet format partitioned by year - append to an existing file | |
df.write.partitionBy('year').format('parquet').mode('append').save(parquet_file_path) | |
# Write data frame as a Hive table | |
df.write.bucketBy(10, "year").sortBy("avg_ratings").saveAsTable("films_bucketed") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment