使用R通过钻取将数据帧写入hdfs

时间:2015-12-30 07:42:20

标签: r hdfs

n = c(2, 3, 5) 
s = c("aa", "bb", "cc") 
b = c(TRUE, FALSE, TRUE) 
df = data.frame(n, s, b) 
ch <- odbcConnect("Drill")
sqlSave(ch, df, tablename = "tblTest", rownames=FALSE, append=TRUE)

当我执行上面的代码时,它抛出异常:

Error in sqlSave(ch, df, tablename = "tblTest", rownames = FALSE, append = FALSE) : 
  HY000 1040 [MapR][Drill] (1040) Drill failed to execute the query: CREATE TABLE "tblTest"  ("n" DOUBLE, "s" varchar(255), "b" varchar(255))
[30024]Query execution error. Details:[ 
ParseException: Encountered "\"" at line 1, column 14.
Was expecting one of:
    <IDENTIFIER> ...
    <QUOTED_IDENTIFIER> ...
    <BACK_QUOTED_IDENTIFIER> ...
    <BRACKET_QUOTED_IDENTIFIER> ...
    <UNICODE_QUOTED_IDENTIFIER> ...

] 

我在互联网上研究了很长时间,但仍然无法找到解决方案。有人可以帮忙吗?谢谢。

1 个答案:

答案 0 :(得分:1)

也许您应该查看rhdfs包裹? https://github.com/RevolutionAnalytics/rhdfs