如果Spark存在错误,则删除Hive表

时间:2014-07-21 04:26:20

标签: mysql hive apache-spark

我有Hive,MySQL和Spark。 MySQL是Hive metastore_db。我按照本指南来配置它(http://www.cloudera.com/content/cloudera-content/cloudera-docs/CDH4/4.2.0/CDH4-Installation-Guide/cdh4ig_topic_18_4.html)。我可以在hive shell环境下执行drop table命令。但是当我进入spark-shell env时,我使用hiveContext.hql("DROP TABLE IF EXISTS hivetesting")。然后,我得到以下错误:

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)
......

每个命令都在hive shell下成功运行。同时,hiveContext在show tables下可以create table src(id string) select count(*) from srcspark-shell如果表不存在,则删除表除外。表存在时,Drop表可以成功运行。

我该怎么做才能解决这个问题?

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

Spark 1.5.1中不存在此问题;我能够成功致电

hiveContext.sql('DROP TABLE IF EXISTS test_table')

Spark是一个快速发展的平台,不同版本之间会发生变化。