title: Spark 2.0 - "Table or view not found" when querying Hive.( Spark cant see hive tables )
body: <p>When querying Hive via <code>spark-shell</code> 2.0:</p>
  
  <pre><code>spark.sql("SELECT * FROM schemaname.tablename")
  </code></pre>
  
  <p>It throws an error:</p>
  
  <pre><code>16/08/13 09:24:17 INFO execution.SparkSqlParser: Parsing command: SELECT * FROM schemaname.tablename
  org.apache.spark.sql.AnalysisException: Table or view not found: `schemaname`.`tablename`; line 1 pos 14
  ...
  </code></pre>
  
  <p>Hive access seems to be properly configured via <code>hive-site.xml</code>. In shell Spark is printing:</p>
  
  <pre><code>scala&gt; spark.conf.get("spark.sql.warehouse.dir")
  res5: String = /user/hive/warehouse
  </code></pre>
  
  <p>Inside <code>conf/hive-site.xml</code>, Hive is configured and its configurations can be accessed on Spark. When listing the databases, it shows the existing <code>default</code> database. But it doesn't show the tables that are inside <code>default</code>.</p>
  
  <pre><code>scala&gt; spark.catalog.listDatabases.show(false)
  +-------+----------------+---------------------------------------------+
  |name   |description     |locationUri                                  |
  +-------+----------------+---------------------------------------------+
  |default|default database|hdfs://hdfs-server-uri:8020/user/hive/warehouse|
  +-------+----------------+---------------------------------------------+
  
  scala&gt; spark.catalog.listTables("default").show()
  +----+--------+-----------+---------+-----------+
  |name|database|description|tableType|isTemporary|
  +----+--------+-----------+---------+-----------+
  +----+--------+-----------+---------+-----------+
  </code></pre>
  
  <p>Why can't Spark see my Hive Tables?</p>