title: SparkSession: ActiveSession vs DefaultSession
body: <p>According to the API docs: </p>
  
  <blockquote>
    <p><code>getActiveSession</code>() Returns the active SparkSession for the current
    thread, returned by the builder. </p>
    
    <p><code>getDefaultSession</code>() Returns the
    default SparkSession that is returned by the builder.</p>
  </blockquote>
  
  <p>I was (most likely erroneously) using <code>getActiveSession</code> to retrieve the <code>SparkSession</code> or <code>SparkContext</code> in some functions across multiple threads. Sometimes the activeSession was not defined (most likely because the thread had just started up).</p>
  
  <p>Can someone explain the difference between the two, or is the API doc sufficiently self-explanatory?</p>
  
  <p>Also, when would I use <code>getActiveSession</code> if </p>
  
  <ol>
  <li><p>In 99% of apps there is only one session and</p></li>
  <li><p><code>getDefaultSession</code> should return that session</p></li>
  </ol>