title: HiveContext.sql() gives runtime No Such Method Error
body: <p>Hi I am trying to run a simple java program using Apache Hive and Apache Spark. The program compiles without any error, but on runtime I get the following error:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoSuchMethodError: org.apache.spark.sql.hive.HiveContext.sql(Ljava/lang/String;)Lorg/apache/spark/sql/DataFrame;
  at SparkHiveExample.main(SparkHiveExample.java:13)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:743)
  at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:187)
  at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:212)
  at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:126)
  at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
  </code></pre>
  
  <p>Following is my code:</p>
  
  <pre><code> import org.apache.spark.SparkContext;
   import org.apache.spark.SparkConf;
   import org.apache.spark.sql.hive.HiveContext;
   import org.apache.spark.sql.DataFrame;
   public class SparkHiveExample {
   public static void main(String[] args) {
   SparkConf conf = new SparkConf().setAppName("SparkHive Example");
   SparkContext sc = new SparkContext(conf);
   HiveContext hiveContext = new HiveContext(sc);
  
   System.out.println("Hello World");
   DataFrame df = hiveContext.sql("show tables");
   df.show();
   }
  }
  </code></pre>
  
  <p>My pom.xml file looks as follows:</p>
  
  <pre><code>&lt;project&gt;
    &lt;groupId&gt;edu.berkeley&lt;/groupId&gt;
    &lt;artifactId&gt;simple-project&lt;/artifactId&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;name&gt;Simple Project&lt;/name&gt;
    &lt;packaging&gt;jar&lt;/packaging&gt;
    &lt;version&gt;1.0&lt;/version&gt;
    &lt;dependencies&gt;
       &lt;dependency&gt; &lt;!-- Spark dependency --&gt;
          &lt;groupId&gt;org.apache.spark&lt;/groupId&gt;
          &lt;artifactId&gt;spark-core_2.10&lt;/artifactId&gt;
          &lt;version&gt;1.3.0&lt;/version&gt;
       &lt;/dependency&gt;
       &lt;dependency&gt;
          &lt;groupId&gt;org.apache.spark&lt;/groupId&gt;
          &lt;artifactId&gt;spark-hive_2.10&lt;/artifactId&gt;
          &lt;version&gt;1.3.0&lt;/version&gt;
       &lt;/dependency&gt;
   &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>What could be the problem?</p>
  
  <p>EDIT: I tried using SQLContext.sql() method and I still get a similar method not found runtime error. <a href="https://stackoverflow.com/a/29712576/6526073">This</a> stackoverflow answer suggests that the problem is caused due to dependency problem, but I am unable to figure out what.</p>