Print SparkSession Config Options
<p>When I start pyspark, a SparkSession is automatically generated and available as 'spark'. I would like to print/view the details of the spark session but am having a lot of difficulty accessing these parameters. </p>

<p>Pyspark auto creates a SparkSession. This can be created manually using the following code:</p>

<pre><code>from pyspark.sql import SparkSession
spark = SparkSession.builder.appName("PythonSQL")\ 
        .config("spark.some.config.option", "some-value")\ 
        .getOrCreate()
</code></pre>

<p>I would like to view/print the appname and config options. The reason I would like to see these is as a result of another issue that I am experiencing which this may shed light on.</p>

<p>Application name can be accessed using <code>SparkContext</code>:</p>

<pre><code>spark.sparkContext.appName
</code></pre>

<p>Configuration is accessible using <code>RuntimeConfig</code>:</p>

<pre><code>from py4j.protocol import Py4JError

try: 
   spark.conf.get("some.conf")
except Py4JError as e:
   pass
</code></pre>

python apache-spark pyspark