title: Table or view not found with registerTempTable
body: <p>So I run the following on pyspark shell:</p>
  
  <pre><code>&gt;&gt;&gt; data = spark.read.csv("annotations_000", header=False, mode="DROPMALFORMED", schema=schema)
  &gt;&gt;&gt; data.show(3)
  +----------+--------------------+--------------------+---------+---------+--------+-----------------+
  |   item_id|           review_id|                text|   aspect|sentiment|comments| annotation_round|
  +----------+--------------------+--------------------+---------+---------+--------+-----------------+
  |9999900031|9999900031/custom...|Just came back to...|breakfast|        3|    null|ASE_OpeNER_round2|
  |9999900031|9999900031/custom...|Just came back to...|    staff|        3|    null|ASE_OpeNER_round2|
  |9999900031|9999900031/custom...|The hotel was loc...|    noise|        2|    null|ASE_OpeNER_round2|
  +----------+--------------------+--------------------+---------+---------+--------+-----------------+
  &gt;&gt;&gt; data.registerTempTable("temp")
  &gt;&gt;&gt; df = sqlContext.sql("select first(item_id), review_id, first(text), concat_ws(';', collect_list(aspect)) as aspect from temp group by review_id")
  &gt;&gt;&gt; df.show(3)
  +---------------------+--------------------+--------------------+--------------------+
  |first(item_id, false)|           review_id|  first(text, false)|              aspect|
  +---------------------+--------------------+--------------------+--------------------+
  |               100012|100012/tripadviso...|We stayed here la...|          staff;room| 
  |               100013|100013/tripadviso...|We stayed for two...|           breakfast|
  |               100031|100031/tripadviso...|We stayed two nig...|noise;breakfast;room|
  +---------------------+--------------------+--------------------+--------------------+
  </code></pre>
  
  <p>and it works perfectly with the shell sqlContext variable.</p>
  
  <p>When I write it as a script:</p>
  
  <pre><code>from pyspark import SparkContext
  from pyspark.sql import SparkSession, SQLContext
  
  sc = SparkContext(appName="AspectDetector")
  spark = SparkSession(sc)
  sqlContext = SQLContext(sc)
  data.registerTempTable("temp")
  df = sqlContext.sql("select first(item_id), review_id, first(text), concat_ws(';', collect_list(aspect)) as aspect from temp group by review_id")
  </code></pre>
  
  <p>and run it I get the following: </p>
  
  <blockquote>
    <p>pyspark.sql.utils.AnalysisException: u'Table or view not found: temp;
    line 1 pos 99'</p>
  </blockquote>
  
  <p>How is that possible? Am I doing something wrong on the instatiation of sqlContext?</p>