title: Drop Hive Table If Exists Error by Spark
body: <p>I have Hive, MySQL and Spark. MySQL is Hive metastore_db. I follow this guide to configurate it (<a href="http://www.cloudera.com/content/cloudera-content/cloudera-docs/CDH4/4.2.0/CDH4-Installation-Guide/cdh4ig_topic_18_4.html" rel="nofollow">http://www.cloudera.com/content/cloudera-content/cloudera-docs/CDH4/4.2.0/CDH4-Installation-Guide/cdh4ig_topic_18_4.html</a>). It is ok for me to do drop table command under hive shell environment. But when I enter into spark-shell env, I use <code>hiveContext.hql("DROP TABLE IF EXISTS hivetesting")</code>. And then, I get following error:</p>
  
  <pre><code>ERROR Hive: NoSuchObjectException(message:default.hivetesting table not found)
  at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$get_table_result$get_table_resultStandardScheme.read(ThriftHiveMetastore.java:27129)
  at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$get_table_result$get_table_resultStandardScheme.read(ThriftHiveMetastore.java:27097)
  at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$get_table_result.read(ThriftHiveMetastore.java:27028)
  at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:78)
  at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$Client.recv_get_table(ThriftHiveMetastore.java:936)
  at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$Client.get_table(ThriftHiveMetastore.java:922)
  at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.getTable(HiveMetaStoreClient.java:854)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)
  at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.invoke(RetryingMetaStoreClient.java:89)
  at com.sun.proxy.$Proxy11.getTable(Unknown Source)
  at org.apache.hadoop.hive.ql.metadata.Hive.getTable(Hive.java:950)
  ......
  </code></pre>
  
  <p>Every command is running successfully under <code>hive shell</code>. Meanwhile, <code>show tables</code> <code>create table src(id string)</code> and <code>select count(*) from src</code> are ok under <code>spark-shell</code> by hiveContext. <strong>Except drop table if the table not exists.</strong> Drop table can be run successfully when the table exists. </p>
  
  <p>What can I do to get this resolved?</p>
  
  <p>Any help is highly appreciated.</p>