java.sql.SQLException: org.apache.thrift.transport.TTransportException in hive?

It is a very generic error message describing that the hiveserver is having a problem and suggesting you to take a look at the Hive logs. If you access the hive logs and find the exception call stack, you can find the root cause or if you share the exception, I might be able to help you.

Most common problems I have seen as:

  1. Issues with meta store related with concurrency

  2. When you start hive server as $hive --service yourhiveserver and keep it running for days and then run your code, it is possible that your connection is broker to server and you will get exact same error. If you reconnect to server and this error will go away. This is only because after some time wait_time expired and disconnect happen.

  3. Port specific errors

Be sure to setup an open Port for your Hive Server and set it as below before starting hive server:

 $export HIVE_PORT=10000
 $hive --service hiveserver
 $ _run_your_code

There could be other reasons, however your best option is to check the call stack in hive logs to root cause and solve the problem.