title: Executing multiple SQL queries on Spark
body: <p>I have a Spark SQL query in a file test.sql - </p>
  
  <pre class="lang-sql prettyprint-override"><code>CREATE GLOBAL TEMPORARY VIEW VIEW_1 AS select a,b from abc
  
  CREATE GLOBAL TEMPORARY VIEW VIEW_2 AS select a,b from VIEW_1
  
  select * from VIEW_2
  </code></pre>
  
  <p>Now, I start my spark-shell and try to execute it like this - </p>
  
  <pre class="lang-scala prettyprint-override"><code>val sql = scala.io.Source.fromFile("test.sql").mkString
  spark.sql(sql).show
  </code></pre>
  
  <p>This fails with the following error - </p>
  
  <pre><code>org.apache.spark.sql.catalyst.parser.ParseException:
  mismatched input '&lt;' expecting {&lt;EOF&gt;, 'GROUP', 'ORDER', 'HAVING', 'LIMIT', 'OR', 'AND', 'WINDOW', 'UNION', 'EXCEPT', 'MINUS', 'INTERSECT', 'SORT', 'CLUSTER', 'DISTRIBUTE'}(line 1, pos 128)
  </code></pre>
  
  <p>I tried to execute these queries 1 by 1 in different spark.sql statements and it runs fine. The problem is, I have 6-7 queries which creates temporary views and finally i need output from my last view. Is there a way through which i can run these SQL's in a single spark.sql statement. I have worked on Postgres SQL (Redshift) and that is able to execute such kind of queries. In spark sql, i will have to maintain a lot of files in this case. </p>