我正在尝试使用来自Rstudio的PostgreSQL
包从外部SparkR
数据库中读取数据,但继续获取参数的错误长度为零。以下是我的代码:
# set db variables
jdbcUrl = "jdbc:postgresql://db.host.url:5432/db_name"
username = "db_username"
pw = "db_password"
# define query
df_column_names <- c("id", "date", "datetime", "address", "name")
df_query <- sprintf("SELECT %s FROM schema.table_name;",
noquote(paste0(outcome_column_names, collapse = ",")))
# read from db
DF = read.jdbc(url = jdbcUrl,
tableName = df_query,
partitionColumn = "id",
user = username,
password = pw)
上述代码导致以下错误:
Error: Error in jdbc : argument is of length zero
我试图将read.jdbc
的参数作为字符串插入,但它仍然返回相同的错误。我也用谷歌搜索,但找不到相同的问题。我在这里缺少什么?