How to Connect RStudio Server Pro to HDP Hive

rstudio
rstudio-server-pro
ide-issue
#1

Hello,

We are trying to connect our RStudio to hive using the following code:

install.packages("rJava")
install.packages("RJDBC",dep=TRUE)
options( java.parameters = "-Xmx8g" )
library("DBI")
library("rJava")
library("RJDBC")

cp = c("/usr/hdp/current/hive-client/lib/hive-jdbc.jar",
"/usr/hdp/current/hadoop-client/hadoop-common.jar")
.jinit(classpath=cp)

drv <- JDBC("org.apache.hive.jdbc.HiveDriver",
"/usr/hdp/current/hive-client/lib/hive-jdbc.jar",
identifier.quote="`")

conn <- dbConnect(drv, "jdbc:hive2:<SERVER_NAME>", "user", "pass")

show_databases <- dbGetQuery(conn, "show databases")

show_databases

Currently, I get "java.lang.NoClassDefFoundError: org/apache/thrift/TException", however previously when I reinstalled the packages I got "java.lang.NoClassDefFoundError: Could not initialize class org.apache.hadoop.security.JniBasedUnixGroupsMappingWithFallback"

This seems like an issue with the library not being loaded in the classpath which I am currently debugging. Is there another method to connect RStudio to Hive or has anyone encountered a similar difficulty?

Thanks!

0 Likes

#2

Another option would be to use ODBC instead of JDBC. Here are a couple of links that may be of help on how to set that up:

1 Like

#3

Thanks edgaruiz, I'll try that out.

0 Likes