If you get the below error when trying out any queries in hive,
So, go to the metastore/metastore_db and verify if your user id has permissions by doing an ls -lrt. If your userid does not have permissions, you should grant write permissions to it. Below are the commands :
Step 1: search the location of metastore_db in hive-site.xml
cd /usr/lib/hive/conf
grep metastore_db hive-site.xml
Now go to your the directory where your metastore_db is present. (Mine is at /var/lib/hive/metastore)
cd /var/lib/hive/metastore/metastore_db
sudo chmod a+rwx . –recursive
sudo \rm *.lck
Now you can enter hive shell and the queries will not give any exception