[ 
https://issues.apache.org/jira/browse/HIVE-187?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Eric Hwang updated HIVE-187:
----------------------------

      Tags: ODBC
    Status: Patch Available  (was: Open)

Hi All,

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
$ ./bootstrap.sh
$ ./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
$ 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:
[Hive]
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.

> ODBC driver
> -----------
>
>                 Key: HIVE-187
>                 URL: https://issues.apache.org/jira/browse/HIVE-187
>             Project: Hadoop Hive
>          Issue Type: New Feature
>          Components: Clients
>    Affects Versions: 0.2.0
>            Reporter: Raghotham Murthy
>            Assignee: Eric Hwang
>             Fix For: 0.4.0
>
>         Attachments: HIVE-187.1.patch
>
>
> We need to provide the a small number of functions to get basic query
> execution and retrieval of results. This is based on the tutorial provided
> here: http://www.easysoft.com/developer/languages/c/odbc_tutorial.html
>  
> The minimum set of ODBC functions required are:
> SQLAllocHandle - for environment, connection, statement
> SQLSetEnvAttr
> SQLDriverConnect
> SQLExecDirect
> SQLNumResultCols
> SQLFetch
> SQLGetData
> SQLDisconnect
> SQLFreeHandle
>  
> If required the plan would be to do the following:
> 1. generate c++ client stubs for thrift server
> 2. implement the required functions in c++ by calling the c++ client
> 3. make the c++ functions in (2) extern C and then use those in the odbc
> SQL* functions
> 4. provide a .so (in linux) which can be used by the ODBC clients.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to