I have attached the first version of the patch for the Hive ODBC driver. Please keep in mind that this is still an initial version and is still very rough around the edges. However, it provides basic ODBC 3.51 API support for connecting, executing queries, fetching, etc. This driver has been successfully tested on 32-bit and 64-bit linux machines with iSQL. It has also been tested with partial success on applications such as MicroStrategy. The driver consists of two sections: the Hive client and the unixODBC API wrapper. The patch only contains the Hive client, while the unixODBC portion will be uploaded as a separate attachment that will not be part of this repository (for licensing reasons).
My development environment for this driver is as follows:
gcc/g++ version: (GCC) 4.0.2 20051125 (Red Hat 4.0.2-8)
thrift trunk version: r790732 (the latest revision should be fine)
Instructions to build and use the Hive ODBC Driver:
I. Building Thrift:
1. Get the latest revision of Thrift from http://incubator.apache.org/thrift/download/.
2. Make and install thrift after tar extraction with the following commands (courtesy of Raghu):
- Configure and build thrift compiler and libraries
$ cd thrift-instant-r790732
$ ./configure --without-csharp --without-ruby --prefix=<thrift_install_path> && make -j4
- Install thrift
$ make install
- Configure, build, and install fb303
$ cd contrib/fb303
$ ./configure --with-thriftpath=<thrift_install_path> --prefix <thrift_install_path>
$ make && make install
2a. I have also attached the precompiled Linux 32bit and 64bit versions of Thrift for your convenience.
II. Building the Hive client (requires step I):
1. From the hive root directory, run:
$ ant compile-cpp -Dthrift.home=<thrift_install_path>
- <thrift_install_path> should be an absolute path (a.k.a not relative) pointing to the root Thrift installation directory. The <thrift_install_path> referenced in parts I and II should have the same value.
- You may optionally add '-Dword.size' with a value of 32 or 64 to specify the type of architecture the driver should compile into, but will detect this automatically on its own if unspecified.
- If you get an undefined reference to vtables error, make sure that you specified the complete absolute path for thrift.home.
2. Manually install the Hive client libraries by copying the contents of <hive_root>/build/odbc/lib and <hive_root>/build/odbc/include into the corresponding system folders. You may have to run ldconfig to update the dynamic linker's runtime libraries.
NOTE: the compiled static library, libhiveclient.a, requires linking with stdc++ as well as thrift to function properly.
3. When running the Hive test suite with 'ant test', specifying the argument '-Dthrift.home=<thrift_install_path>' will enable the tests for the Hive client. Keep in mind that the Hive client tests require a locally running Hive server on port 10000 to execute properly. I apologize for the messiness of the test code, which I whipped up rather quickly. This should be remedied in a later revision.
III. Building unixODBC (requires step II):
1. After extracting the unixODBC attachment, run:
$ ./configure --enable-gui=no
$ make install
- This will compile and install all of unixODBC, including the ODBC API wrapper for the Hive client. The ODBC API wrapper for the Hive client should be called libodbchive.so.
IV. Installing the Hive driver into a Driver Manager (requires all prior steps):
1. Find the odbc.ini file corresponding to the desired ODBC Driver Manager. If you are using unixODBC's Driver Manager, you should be able to run 'odbcinst -j' to list out the paths to important configuration files.
2. Add the following entry to odbc.ini:
Driver = <path_to_libodbchive.so>
Description = Hive Driver v1
DATABASE = default
HOST = <Hive_server_address>
PORT = <Hive_server_port>
FRAMED = 0
Now you should be able to test out the new Hive ODBC driver with your applications that connect through this Driver Manager. If the Driver Manager reports that it cannot open the driver's shared library, make sure that libodbchive.so and libhiveclient.so have all dynamic library paths resolved and that they are both compiled into the proper architecture (32 or 64 bit). Tell me if you find the instructions to be confusing or incomplete.