简体   繁体   English

无法将配置单元表加载到Spark

[英]Not able to load hive table into Spark

I am trying to load data from hive table using spark-sql. 我正在尝试使用spark-sql从蜂巢表中加载数据。 However, it doesn't return me anything. 但是,它什么也没有回报我。 I tried to execute the same query in hive and it prints out the result. 我试图在配置单元中执行相同的查询,并打印出结果。 Below is my code which I am trying to execute in scala. 以下是我试图在Scala中执行的代码。

sc.setLogLevel("ERROR")
import org.apache.spark.sql.DataFrame
import org.apache.spark.sql.Row
import org.apache.spark.sql.types.{StructField, StructType, LongType}
import org.apache.spark.sql.hive.HiveContext
import sqlContext.implicits._
val sqlContext = new HiveContext(sc)
sqlContext.setConf("spark.sql.hive.convertMetastoreOrc", "false")
val data = sqlContext.sql("select `websitename` from db1.table1 limit 10").toDF

Kindly let me know what could be the possible reason. 请让我知道可能是什么原因。

  • Spark- version : 1.6.2 Spark-版本:1.6.2
  • Scala - 2.10 Scala-2.10

Depends how the table was created in the first place. 取决于表的创建方式。 If it was created by an external application and you have hive running as separate service make sure that the settings in SPARK_HOME/conf/hive-site.xml are correct. 如果它是由外部应用程序创建的,并且您已将hive作为单独的服务运行,请确保SPARK_HOME / conf / hive-site.xml中的设置正确。

If it's an internal spark-sql table, it sets up the metastore in a folder on the master node, which in your case might have been deleted or moved. 如果它是内部spark-sql表,它将在主节点上的文件夹中设置元存储,在您的情况下,该文件夹可能已被删除或移动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM