from pyspark.sql import SparkSession spark = SparkSession.builder.getOrCreate() spark.sparkContext.setLogLevel("ERROR") sc = spark.sparkContext print(f"scheduler_mode={sc.getConf().get('spark.scheduler.mode')}") print(f"allocation_file={sc.getConf().get('spark.scheduler.allocation.file')}") sc.setLocalProperty("spark.scheduler.pool", "interactive") interactive_count = spark.range(0, 20).repartition(4).count() interactive_pool = sc.getLocalProperty("spark.scheduler.pool") print(f"interactive_pool={interactive_pool}") print(f"interactive_count={interactive_count}") sc.setLocalProperty("spark.scheduler.pool", "batch") batch_count = spark.range(0, 10).repartition(2).count() batch_pool = sc.getLocalProperty("spark.scheduler.pool") print(f"batch_pool={batch_pool}") print(f"batch_count={batch_count}") sc.setLocalProperty("spark.scheduler.pool", None) print(f"cleared_pool={sc.getLocalProperty('spark.scheduler.pool')}") spark.stop() print("spark_stopped=true")