Apache Spark咨询表的问题

时间:2015-03-06 12:38:26

标签: hadoop hive apache-spark hiveql

我尝试火花和蜂巢, 我想选择一个表

hiveContext.hql("select * from final_table").collect()

但我有这个错误

ERROR Hive: NoSuchObjectException(message:default.final_table table not found)
at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.get_table(HiveMetaStore.java:1569)
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.RetryingHMSHandler.invoke(RetryingHMSHandler.java:106)
at com.sun.proxy.$Proxy27.get_table(Unknown Source)
at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.getTable(HiveMetaStoreClient.java:1008)
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:90)
at com.sun.proxy.$Proxy28.getTable(Unknown Source)
at org.apache.hadoop.hive.ql.metadata.Hive.getTable(Hive.java:1000)
at org.apache.hadoop.hive.ql.metadata.Hive.getTable(Hive.java:974)
at org.apache.spark.sql.hive.HiveMetastoreCatalog.lookupRelation(HiveMetastoreCatalog.scala:70)
at org.apache.spark.sql.hive.HiveContext$$anon$2.org$apache$spark$sql$catalyst$analysis$OverrideCatalog$$super$lookupRelation(HiveContext.scala:253)
at org.apache.spark.sql.catalyst.analysis.OverrideCatalog$$anonfun$lookupRelation$3.apply(Catalog.scala:141)
at org.apache.spark.sql.catalyst.analysis.OverrideCatalog$$anonfun$lookupRelation$3.apply(Catalog.scala:141)
at scala.Option.getOrElse(Option.scala:120)

但是当我尝试这个时

hiveContext.hql("CREATE TABLE IF NOT EXISTS TestTable (key INT, value STRING)")

我没有任何问题,表格已经创建。

关于这个问题的任何想法,任何解决方案?

谢谢!

1 个答案:

答案 0 :(得分:0)

您使用哪个命令启动Spark?很可能您没有以正确的方式设置Hive Metastore的使用,这意味着每次启动集群时都会创建新的临时本地Metastore。要使用Hive Metastore,请遵循以下指南:(Run Spark with build-in Hive and Configuring a remote PostgreSQL database for the Hive Metastorehttps://spark.apache.org/docs/latest/sql-programming-guide.html#hive-tables)。这样,您创建的表将在Hive Metastore中的群集重新启动之间保持不变。