SummerEla
SummerEla

Reputation: 1952

Installing Cloudera Impala ODBC drivers for RODBC

I have tried to very carefully follow the installation guide for setting up Impala Cloudera ODBC drivers for R on a mac, but keep getting the following error message:

In odbcDriverConnect("DSN=Impala ODBC Driver") :
[RODBC] ERROR: state IM002, code 0, message [unixODBC][Driver
Manager]Data source name not found, and no default driver specified

Here's exactly what I did. For each file referenced below, I made sure the file exists at that location.

Download and install the Impala ODBC driver from http://www.cloudera.com/content/cloudera/en/downloads/connectors/impala/odbc/impala-odbc-v2-5-23.html

brew install unixodbc
odbcinst -j 

unixODBC 2.3.2
DRIVERS............: /usr/local/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/etc/odbc.ini
FILE DATA SOURCES..: /usr/local/etc/ODBCDataSources
USER DATA SOURCES..: /Users/summerrae/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8

Pointed the DYLD library path variable:

export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/opt/cloudera/impalaodbc/lib/universal

echo "export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/opt/cloudera/impalaodbc/lib/universal/" >> ~/.bashrc

Edited /usr/local/etc/odbc.ini:

[ODBC Data Sources]
# Use this name in your connection string 
Impala DSN=Impala ODBC Driver
[Impala DSN]
# Driver: The location where the ODBC driver is installed to. 
Driver=/opt/cloudera/impalaodbc/lib/universal/libclouderaimpalaodbc.dylib
# Values for HOST, PORT, Database 
HOST=myhost (changed name here for security)
PORT=21050
Database=default

Edited /user/local/etc/odbcinst.ini: 
[ODBC Drivers]
Impala ODBC Driver=Installed
[Impala ODBC Driver]
Description=Impala ODBC Driver
Driver=/opt/cloudera/impalaodbc/lib/universal/libclouderaimpalaodbc.dylib

Edited /opt/cloudera/impalaodbc/lib/universal/cloudera.impalaodbc.ini:

[Driver]
## - Note that this default DriverManagerEncoding of UTF-15 
## is for unixODBC. 
DriverManagerEncoding=UTF-16
ErrorMessagesPath=/opt/cloudera/impalaodbc/ErrorMessages/
LogLevel=0
LogPath=

## - Note that the path to your ODBC Driver Manager 
## must be specified in DYLD_LIBRARY_PATH.
# unixODBC 
ODBCInstLib=libiodbcinst.dylib

Exported path variables to ~/.bashrc:

#add full path to odbc.ini and add to bashrc
export ODBCINI=/usr/local/etc/odbc.ini
echo "export ODBCINI=/etc/odbc.ini" >> ~/.bashrc

#add directory path to odbcinst.ini and add to bashrc
export ODBCSYSINI=/usr/local/etc/
echo "export ODBCSYSINI=/etc/odbcinst.ini" >> ~/.bashrc

#add full path to cloudera.impalaodbc.ini and add to bashrc
export CLOUDERAIMPALAINI=/opt/cloudera/impalaodbc/lib/universal/cloudera.impalaodbc.ini
echo "export CLOUDERAIMPALAINI=/opt/cloudera/impalaodbc/lib/universal/cloudera.impalaodbc.ini" >> ~/.bashrc

In R:

install.packages("RODBC")
library(RODBC)
#connect using impala DSN
conn <- odbcConnect("Impala DSN")

I have gone through every tutorial I can find to get this to work. I am able to connect to the same server and parameters using Python, I am able to connect to the same server using RImpala, but can't get the RImpala package to run queries, so I know the connection works. Any help is greatly appreciated. Thanks!

Upvotes: 2

Views: 4204

Answers (2)

avidenic
avidenic

Reputation: 643

Your issue was that the driver installation was pointing to filed in /usr/local/etc folder for configuration and you were trying to modify the ones that came with the driver. I had the same problem and I just configured .ini files in /usr/local/etc and could connect DNS-less.

Upvotes: 0

SummerEla
SummerEla

Reputation: 1952

It turned out to be a problem with iODBC drivers that came default with yosemite. I ended up reinstalling mac os, and everything worked great.

As an alternative, I also found that you can:

Install mac ODBC manager

  1. Download file from http://www.odbcmanager.net/
  2. Once installed, open the program from Applications/Utilities
  3. Click on "Drivers" and then "Add"
  4. Browse to the impala driver, default location is: /opt/cloudera/impalaodbc/lib/universal/libclouderaimpalaodbc.dylib
  5. Add a System DSN
  6. Add a DSN Name, then click on "Add"
  7. Add the following two key-value pairs:

    HOST your_host_name

    PORT 21050

  8. Click "OK"

Connect with RODBC using the DSN name you created above.

Upvotes: 4

Related Questions