I am interacting with a HIVE database using RStudio and RJDBC.
I can create a connection a db connection and use it as follows.
library(dplyr)
library(dbplyr)
library(DBI)
library(tidyr)
library(readr)
library(haven)
library(stringi)
library(readxl)
library(RSQLite)
library(StatMatch)
library(transport)
library(purrr)
library(sparklyr)
library(dplyr)
library("DBI")
library(tcltk)
options(java.parameters = "-Xmx8G") # or whatever g u wanna set to
library("rJava")
library("RJDBC")
cp = c("/usr/lib/hive/hive-jdbc.jar"
, "/usr/lib/hive/hadoop-common.jar"
, "/usr/lib/hive/libthrift-0.9.2.jar"
, "/usr/lib/hive/hive-service.jar"
, "/usr/lib/hive/httpclient-4.2.5.jar"
, "/usr/lib/hive/httpcore-4.2.5.jar"
, "/usr/lib/hive/hive-jdbc-standalone.jar")
.jinit(classpath=cp)
drv <- JDBC("org.apache.hive.jdbc.HiveDriver"
, "hive-jdbc.jar" )
conn <- dbConnect(drv
, "jdbc:hive2://myhadoopcluster:10000/default"
, "myusername", "mypassword")
databases <- dbGetQuery(conn, "show databases")
works fine
kpfilenames<-dbListTables(conn)
also gives me a list of tables
However, when I want to get a connection to a table using the tbl function I get the following error:
kp1<-tbl(src_dbi(conn),"coreprofileformammain")
Error in .verify.JDBC.result(r, "Unable to retrieve JDBC result set for ", :
Unable to retrieve JDBC result set for SELECT *
FROM "coreprofileformammain" AS "zzz1"
WHERE (0 = 1) (Error while compiling statement: FAILED: ParseException line 2:5 cannot recognize input near '"coreprofileformammain"' 'AS' '"zzz1"' in join source)
The error seems to indicate that tbl is putting double quotes around the table names in the sql call
In fact, I get the identical error in HUE if I put quotes around the table names in the query.
Error while compiling statement: FAILED: ParseException line 2:5 cannot recognize input near '"coreprofileformammain"' 'AS' '"zzz1"' in join source
But in HUE the query of course runs correctly if the quotes are not present.
How do I get tbl to NOT pass the quotes through the database driver?