0

I am trying to load data from hive table using 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.

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
  • Scala - 2.10
Xavier Guihot
  • 54,987
  • 21
  • 291
  • 190
prateek
  • 1
  • 1

1 Answers1

1

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.

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.

jamborta
  • 5,130
  • 6
  • 35
  • 55