title: Apache Livy : How to share the same spark session?
body: <p>considering batch mode of livy , 
  I have submitted one file/jar in which my spark logic is written.
  How can I share a spark session created by one <code>POST/batches</code> with say <code>{'id':1}</code> with another <code>POST/batches</code> with <code>{'id':2}</code> ? 
  Reason for doing so is , the transformations I have applied and stored in a dataframe I need to use that in different task by sharing same session ( I can write and then read the result but I want to remove that overhead )</p>
  
  <p><strong>issue:</strong> </p>
  
  <p>Also one issue I am facing is while executing following , I am getting sc/spark not defined if I am using spatk functionality eg <code>sc.parallelize()</code> or <code>spark.read.csv()</code> in my code</p>
  
  <pre class="lang-py prettyprint-override"><code>
  headers = {" Content-type" : "application/json"}
  data = {'file' : '&lt;file/path&gt; ' }
  request.post( host+'/batches' , data= json.dumps(data), headers = headers }
  
  </code></pre>
  
  <p>Is there anything I am missing above because when I do this in <em>interactive</em> mode sc/spark gets initialise automatically ?</p>
  
  <p><strong>Update</strong></p>
  
  <pre class="lang-py prettyprint-override"><code>data = {'kind':'pyspark'}
  r = requests.post(host + '/sessions', data=json.dumps(data),headers=headers)
  
  
  
  data = {'code':'rdd1 = sc.parallelize([1,2,3])'}
  
  rqm = requests.post(host + '/sessions/0/statements', data=json.dumps(data),headers=headers)
  
  pprint.pprint(rqm.json())
  
  rsm = r = requests.get(host + '/sessions/0/statements')
  
  pprint.pprint(rsm.json())
  
  
  
  
  data = {'code':'print(rdd1.collect())'}
  
  rqs = requests.post(host + '/sessions/0/statements', data=json.dumps(data),headers=headers)
  
  pprint.pprint(rqs.json())
  
  rss = requests.get(host + '/sessions/0/statements')
  
  pprint.pprint(rss.json())
  
  </code></pre>
  
  <p>This way I have shared <code>sessions</code> and access <code>rdd</code> in interactive mode.
  How can I do the same in <code>batch</code> mode ?</p>
  
  <p>please provide a simple sample code because I am new to livy and its tough for me to understand complex code. </p>