Data Operations and Support
In an Athena Apache Spark notebook, collecting a large DataFrame into Python exhausts driver memory. The analyst needs only total sales for each of 20 regions; which change best meets the need?
Show the answer
Correct answerC. Aggregate sales by region in Spark, then collect.
AWhy not this: Coalescing reduces partition count, not result size, and can also limit parallelism.
BWhy not this: Caching can speed reuse but does not reduce the number of rows transferred by collect.
CWhy this is right: Spark computes the regional totals across executors, leaving only a small result to transfer to the driver.
DWhy not this: Repartitioning changes executor-side distribution but collect still transfers every row to the driver.
Distributed aggregation reduces the dataset to 20 regional totals before collection, keeping driver memory requirements small. Repartitioning changes data distribution but does not reduce the total data that collect brings to the driver.