Subdomain 1.5: Configure Spark partitioning in distributed data processing, including shuffles and partitions
1.Which of the following Spark configuration properties controls the default number of partitions used when shuffling data for joins or aggregations?
- A.spark.sql.shuffle.partitions
- B.spark.default.parallelism
- C.spark.sql.files.maxPartitionBytes
- D.spark.executor.cores
- E.spark.sql.adaptive.enabled
Show answer & explanation
Correct answer: A — spark.sql.shuffle.partitions
- A. Correct. spark.sql.shuffle.partitions is the specific Spark SQL/DataFrame configuration that sets the default number of partitions to use for shuffle operations caused by wide transformations like joins and aggregations. By default, this is set to 200.
- B. Incorrect. spark.default.parallelism controls the default number of partitions for RDD operations and transformations like parallelize. For Spark SQL and DataFrame operations, Spark uses spark.sql.shuffle.partitions for shuffles.
- C. Incorrect. spark.sql.files.maxPartitionBytes determines the maximum size (in bytes) of a partition when reading data from file-based sources, affecting the initial input partitioning rather than shuffle partitioning.
- D. Incorrect. spark.executor.cores configures the number of CPU cores allocated per executor, which determines how many tasks can run in parallel, but it does not define the number of shuffle partitions.
- E. Incorrect. spark.sql.adaptive.enabled enables Adaptive Query Execution (AQE). While AQE can dynamically adjust and coalesce shuffle partitions at runtime based on statistics, the property that defines the initial default number is spark.sql.shuffle.partitions.