How do we derive partition columns, coalesce partitions to prevent small files, and export to cloud storage with Snappy?
Preparing gold-layer datasets for cloud export with date partitioning, file count optimization, and Snappy compression.
Exporting analytical data marts to AWS S3, Google Cloud Storage, and Snowflake external stages.
from pyspark.sql.functions import col, month, year
mart_df = customer_360 \
.withColumn("order_year", year(col("order_date"))) \
.withColumn("order_month", month(col("order_date"))) \
.coalesce(16)
mart_df.write \
.mode("overwrite") \
.partitionBy("order_year", "order_month") \
.option("compression", "snappy") \
.parquet("s3://warehouse/gold/customer_360")Practice typing production-grade PySpark code for Optimized Partitioning, Coalesce & Parquet Export.