title: What do the SparkSession appName and getOrCreate functions mean?
body: <pre><code>from pyspark.ml.linalg import Vectors
  from pyspark.ml.stat import Correlation
  from pyspark.sql import SparkSession
  
  if __name__ == &quot;__main__&quot;:
      spark = SparkSession \
          .builder \
          .appName(&quot;CorrelationExample&quot;) \
          .getOrCreate()
  
      # $example on$
      data = [(Vectors.sparse(4, [(0, 1.0), (3, -2.0)]),),
              (Vectors.dense([4.0, 5.0, 0.0, 3.0]),),
              (Vectors.dense([6.0, 7.0, 0.0, 8.0]),),
              (Vectors.sparse(4, [(0, 9.0), (3, 1.0)]),)]
      df = spark.createDataFrame(data, [&quot;features&quot;])
  
      r1 = Correlation.corr(df, &quot;features&quot;).head()
      print(&quot;Pearson correlation matrix:\n&quot; + str(r1[0]))
  
      r2 = Correlation.corr(df, &quot;features&quot;, &quot;spearman&quot;).head()
      print(&quot;Spearman correlation matrix:\n&quot; + str(r2[0]))
      # $example off$
  
      spark.stop()
  </code></pre>
  <p>I'm running the above example code from the spark repo at this <a href="https://github.com/apache/spark/blob/master/examples/src/main/python/ml/correlation_example.py" rel="nofollow noreferrer">link</a> .</p>
  <p>What does</p>
  <pre><code>spark = SparkSession \
          .builder \
          .appName(&quot;CorrelationExample&quot;) \
          .getOrCreate()
  </code></pre>
  <p>mean here? What's the purpose of appName here? I don't understand why we would ever need to give the spark session an appName.</p>