Hive Thrift client

Assumptions made: you know what Hive is, you know what Thrift is and you know how to install and start the Hive Thrift server.

To query the Hive server in a language that doesn’t run on the Java Virtual Machine and therefore can’t easily make use of the JBDC drivers, you will need to generate a Thrift client library in your chosen language to use the Thrift Server; as long Thrift has generators for your language of course.

I couldn’t find much documentation online on exactly how to go about this, therefore I thought I’d document the steps I took to generate the Ruby thrift client for Hive, in case someone somewhere wanted to do the same:

cd PATH_TO_HIVE_SOURCE_CODE
thrift —gen rb -I service/include metastore/if/hive_metastore.thrift
thrift —gen rb -I service/include -I . service/if/hive_service.thrift
thrift —gen rb service/include/thrift/fb303/if/fb303.thrift
thrift —gen rb serde/if/serde.thrift
thrift —gen rb ql/if/queryplan.thrift
thrift —gen rb service/include/thrift/if/reflection_limited.thrift
  • Your thrift client will be in the folder: PATH_TO_HIVE_SOURCE_CODE/gen-rb (again replace rb in the generated folder name with your language)
  • You can now copy the generated code around and start using the library to connect with your Hive server

    In Ruby you would use the generated code as follows:

    Or you could use our Ruby thrift client library, we’ve written a thin layer on top of the thrift code to make things a little easier. Feel free to browse and download the code from here:  http://github.com/forward/rbhive