title: Spark application build in local server, how can we access Hive Warehouse located in HDInsight
body: <p>I'm trying to connect to the Hive warehouse directory located in HDInsight by using Spark <strong>local</strong> using IntelliJ Maven. </p>
  
  <p>I am using Spark 1.6 with Scala and Maven Project.</p>
  
  <p>Thrift Server details: </p>
  
  <pre><code>`System.setProperty("hive.metastore.uris", `"thrift://hnaz.xyz123.internal.cloudapp.net:1403")`
  </code></pre>
  
  <p>i am trying to access tables of hive warehouse.</p>
  
  <p>Code :</p>
  
  <pre><code>package Test
  import org.apache.spark.{SparkConf, SparkContext}
  import org.apache.spark.sql.{SQLContext, SaveMode, sources}
  
  
  object TestHive {
    def main(args: Array[String]): Unit = {
  
      // get spark configuration
      val conf = new SparkConf()
        .setAppName("SparkHiveTest")
      conf.setMaster("local[*]")
      System.setProperty("hive.metastore.uris", "thrift://hnaz.xyz123.internal.cloudapp.net:1403")
      import org.apache.spark.sql.hive.HiveContext
      val sc = new  SparkContext(conf)
      val hiveContext = new HiveContext(sc)
      implicit val sqlContext = new SQLContext(sc)
  
      import org.apache.spark.sql.functions._
      import sqlContext.implicits._
  
      val df1 = sqlContext.sql(s"use $data_profiling, sqlContext.sql("show tables")");
  
  
  
    }
  }
  </code></pre>
  
  <p>POM Dependency:</p>
  
  <pre><code> &lt;dependency&gt;
              &lt;groupId&gt;org.apache.spark&lt;/groupId&gt;
              &lt;artifactId&gt;spark-hive_2.11&lt;/artifactId&gt;
              &lt;version&gt;${spark.version}&lt;/version&gt;
              &lt;scope&gt;compile&lt;/scope&gt;
              &lt;!-- provided --&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p>it is throwing error as </p>
  
  <pre><code>" Error:(22, 37) not found: value data_Test
      val df1 = sqlContext.sql(s"use $data_Test, sqlContext.sql("show tables")");"
  
  Error:(22, 74) value tables is not a member of StringContext
      val df1 = sqlContext.sql(s"use $data_Test, sqlContext.sql("show tables")");
  </code></pre>
  
  <p>Thanks a ton. i have only 1 doubt. My Spark is built on a <strong>local server</strong>, and <strong>Hive is located on HDInsight</strong>. How can i access HDInsight Hive from Local Spark. I <strong>don't</strong> have <strong>Spark Cluster on HDInsight</strong>.</p>
  
  <p><strong>Using Client Mode.</strong></p>