How to Recover from Hive SemanticException

In this blog, let’s try to understand how to recover from the Hive SemanticException encountered in production.

Hive SemanticException

Exception occurred while executing hive command:


Usually, to fix any issue we need to understand the root cause of the issue causing it. In software systems, loggers are of great help to get into the root of the problem.

Enable hive Debug Logs

Similarly, to identify the cause of the Hive SemanticException let us enable DEBUG logs for Hive

hive --hiveconf hive.root.logger=DEBUG,console

After enabling debug logs when we execute we get stack trace


Exception in thread "main" java.lang.RuntimeException: org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
    at org.apache.hadoop.hive.ql.session.SessionState.start(



The necessary tables required for the metastore are missing in MySQL. Manually create the tables and restart hive metastore.

The schema files for MySQL will be available under the path

cd $HIVE_HOME/scripts/metastore/upgrade/mysql/

< Login into MySQL >

mysql> drop database IF EXISTS hive;
mysql> create database hive;
mysql> use hive;
mysql> source hive-schema-2.1.1.mysql.sql;


schematool --dbType mysql --initSchema

About the course

The Big Data Architect Masters Program Training is designed to help you gain end to end coverage of Big Data technologies by learning the conceptual implementation of Hadoop 2.x + Quartz Scheduler + Spark using Scala + Kafka + Cassandra + Apache Nifi and Zepplein.


Related Post
Apache Spark : Loading CSV file Using Custom Times... In this blog post, we will see how to load csv which contains timestamp as one of the column. Creating DataFrame from CSV file If you see the below da...

Naveen P.N

12+ years of experience in IT with vast experience in executing complex projects using Java, Micro Services , Big Data and Cloud Platforms. I found NPN Training Pvt Ltd a India based startup to provide high quality training for IT professionals. I have trained more than 3000+ IT professionals and helped them to succeed in their career in different technologies. I am very passionate about Technology and Training. I have spent 12 years at Siemens, Yahoo, Amazon and Cisco, developing and managing technology.