Data Ingestion and Transformation

An AWS Glue Spark job writes each day's output to Amazon S3 as Parquet. Every run produces tens of thousands of files of a few kilobytes each, and Amazon Athena queries on the output have become slow. Which change most directly addresses the problem?

Show the answer

Correct answerC. Reduce the number of Spark partitions with coalesce before writing.

AWhy not this: More workers increase parallelism and can produce even more output files rather than fewer.

BWhy not this: Bookmarks track which input data has been processed; they do not change output file sizes.

CWhy this is right: Fewer Spark partitions at write time produce fewer, larger output files that query engines read efficiently.

DWhy not this: Changing to uncompressed CSV leaves the file count unchanged and makes scans larger and slower.

Spark writes at least one file per partition, so a DataFrame with thousands of partitions produces thousands of tiny files that slow query planning and S3 reads. Coalescing to fewer partitions before the write produces fewer, larger files. More workers add parallelism and can increase the file count.