Support Questions
Find answers, ask questions, and share your expertise

R with Hive


Super Collaborator

check the answer here where it is decribed on how to set up a JDBC connection in R to connect to Hive:

Super Collaborator

not sure if I am getting you right?

If you need some starting point for RStudio, I recommend you some online tutorials for RStudio: But I am no R programmer, so I can't support on specifics of R.

If you need some help on how to work with Hive:

If you need some help on connecting R to Hive, is recommend you the link i sent in the previous post.

New Contributor

@Gayathri Devi

Sample R script:

hadoop.class.path = list.files(path=c("/usr/hdp/"),pattern="jar", full.names=T);
hive.class.path = list.files(path=c("/usr/hdp/current/hive-client/lib"),pattern="jar", full.names=T);
hadoop.lib.path = list.files(path=c("/usr/hdp/current/hive-client/lib"),pattern="jar",full.names=T);
mapred.class.path = list.files(path=c("/usr/hdp/current/hadoop-mapreduce-client/lib"),pattern="jar",full.names=T);
cp = c(hive.class.path,hadoop.lib.path,mapred.class.path,hadoop.class.path)
drv <- JDBC("org.apache.hive.jdbc.HiveDriver","hive-jdbc.jar",identifier.quote="`")
conn <- dbConnect(drv, "jdbc:hive2://ixxx:10000/default", "hive", "hive")
show_databases <- dbGetQuery(conn, "show databases")


hive.class.path = list.files(path=c("/usr/hdp/current/hive-client/lib"), pattern="jar", full.names=T);hadoop.lib.path = list.files(path=c("/usr/hdp/current/hive-client/lib"), pattern="jar", full.names=T);hadoop.class.path = list.files(path=c("/usr/hdp/"), pattern="jar", full.names=T);
cp = c(hive.class.path, hadoop.lib.path, hadoop.class.path, "/usr/hdp/")
drv <- JDBC("org.apache.hive.jdbc.HiveDriver","hive-jdbc.jar",identifier.quote="`")
url.dbc <-paste0("jdbc:hive2://xxx:10000/default");
conn <- dbConnect(drv, url.dbc, "hive", “hive");dbListTables(conn);
Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.