spark 2.1.0 session config settings (pyspark)

前端 未结 5 1122
情深已故
情深已故 2020-12-12 16:27

I am trying to overwrite the spark session/spark context default configs, but it is picking entire node/cluster resource.

 spark  = SparkSession.builder
            


        
5条回答
  •  执念已碎
    2020-12-12 16:47

    You aren't actually overwriting anything with this code. Just so you can see for yourself try the following.

    As soon as you start pyspark shell type:

    sc.getConf().getAll()
    

    This will show you all of the current config settings. Then try your code and do it again. Nothing changes.

    What you should do instead is create a new configuration and use that to create a SparkContext. Do it like this:

    conf = pyspark.SparkConf().setAll([('spark.executor.memory', '8g'), ('spark.executor.cores', '3'), ('spark.cores.max', '3'), ('spark.driver.memory','8g')])
    sc.stop()
    sc = pyspark.SparkContext(conf=conf)
    

    Then you can check yourself just like above with:

    sc.getConf().getAll()
    

    This should reflect the configuration you wanted.

提交回复
热议问题