Create table in hive through spark

61 Views Asked by At

I am trying to connect to Hive through Spark using below code but unable to do so. The code fails with NoSuchDatabaseException Database 'raw' not found. I have database named 'raw' in hive. What am I missing here?

     val spark = SparkSession
      .builder()
      .appName("Connecting to hive")
      .config("hive.metastore.uris", "thrift://myserver.domain.local:9083") 
      .enableHiveSupport() 
      .getOrCreate()

    import spark.implicits._
    import spark.sql
    
    val frame = Seq(("one", 1), ("two", 2), ("three", 3)).toDF("word", "count")
   
    frame.show()
    frame.write.mode("overwrite").saveAsTable("raw.temp1")

Output for spark.sql("SHOW DATABASES")

enter image description here

0

There are 0 best solutions below