0
votes

unable to write the data into hive using pyspark through jupyter notebook .

giving me below error

Py4JJavaError: An error occurred while calling o99.saveAsTable. : org.apache.spark.sql.AnalysisException: java.lang.RuntimeException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient;

Note these steps already tried:

  1. copied the hdfs-site.xml , core-site.xml to /conf of hive
  2. removed metasotore_db and created again using below cmd $HIVE_HOME/bin/schematool –initschema –dbtype derby
1
from pyspark import SparkContext, SparkConf from pyspark.sql import SparkSession, HiveContext SparkContext.setSystemProperty("hive.metastore.uris", "thrift://localhost:10000") sparkSession = SparkSession.builder.appName("example-pyspark-read-and-write").getOrCreate() data = [('First', 1), ('Second', 2), ('Third', 3), ('Fourth', 4), ('Fifth', 5)] df = sparkSession.createDataFrame(data) df.show() # Write into Hive df.write.saveAsTable('example'vikram bhati
this piece of code i tried and giving me error : org.apache.spark.sql.AnalysisException: java.lang.RuntimeException: java.lang.RuntimeException: Unable to instantiatevikram bhati

1 Answers

0
votes

did you use spark-submit for running your script? Also you should add -> ".enableHiveSupport()" like that:

spark = SparkSession.builder \
    .appName("yourapp") \
    .enableHiveSupport() \
    .getOrCreate()