Complete the code to enable dynamic allocation in Spark configuration.
spark.conf.set("spark.dynamicAllocation.enabled", [1])
Setting spark.dynamicAllocation.enabled to "true" activates dynamic resource allocation in Spark.
Complete the code to set the minimum number of executors for dynamic allocation.
spark.conf.set("spark.dynamicAllocation.minExecutors", [1])
The minimum number of executors should be set to "1" or more to ensure at least one executor is allocated.
Fix the error in the code to set the initial number of executors for dynamic allocation.
spark.conf.set("spark.dynamicAllocation.initialExecutors", [1])
The value must be a string representing an integer, not a bare integer. So use "5" with quotes.
Fill both blanks to configure Spark to enable dynamic allocation and set the shuffle tracking mode.
spark.conf.set("spark.dynamicAllocation.enabled", [1]) spark.conf.set("spark.dynamicAllocation.shuffleTracking.enabled", [2])
Both settings should be set to "true" to enable dynamic allocation and shuffle tracking.
Fill all three blanks to create a Spark session with dynamic allocation enabled and set min and max executors.
from pyspark.sql import SparkSession spark = SparkSession.builder.appName("DynamicAllocationApp") .config("spark.dynamicAllocation.enabled", [1]) .config("spark.dynamicAllocation.minExecutors", [2]) .config("spark.dynamicAllocation.maxExecutors", [3]) .getOrCreate()
Enable dynamic allocation with "true", set minimum executors to "1", and maximum to "10" for balanced resource use.
