How do we reduce 200 small partitions down to 4 files before writing without triggering an expensive shuffle?
coalesce(numPartitions) merges adjacent partitions on the same worker without performing a full shuffle.
Preventing the 'small files problem' in data lakes when writing out filtered or aggregated DataFrames.
df_coalesced = df.coalesce(4)Practice typing production-grade PySpark code for Reducing Partition Overhead with coalesce().