title: How to indicate the database in SparkSQL over Hive in Spark 1.3
body: <p>I have a simple Scala code that retrieves data from the Hive database and creates an RDD out of the result set.  It works fine with HiveContext. The code is similar to this:</p>
  
  <pre><code>val hc = new HiveContext(sc)
  val mySql = "select PRODUCT_CODE, DATA_UNIT from account"
  hc.sql("use myDatabase")
  val rdd = hc.sql(mySql).rdd
  </code></pre>
  
  <p>The version of Spark that I'm using is 1.3. The problem is that the default setting for hive.execution.engine is 'mr' that makes Hive to use MapReduce which is slow. Unfortunately I can't force it to use "spark".
  I tried to use SQLContext by replacing hc = new SQLContext(sc) to see if performance will improve. With this change the line </p>
  
  <pre><code>hc.sql("use myDatabase")
  </code></pre>
  
  <p>is throwing the following exception:</p>
  
  <pre><code>Exception in thread "main" java.lang.RuntimeException: [1.1] failure: ``insert'' expected but identifier use found
  
  use myDatabase
  ^
  </code></pre>
  
  <p>The Spark 1.3 documentation says that SparkSQL can work with Hive tables. My question is how to indicate that I want to use a certain database instead of the default one.</p>