[英]Write to Snowflake VARIANT column from R
I am trying to load data to snowflake using the following code, but getting an error.我正在尝试使用以下代码将数据加载到雪花,但出现错误。
con <- DBI::dbConnect(
drv = odbc::odbc(),
driver = "SnowflakeDSIIDriver",
server = "<>",
authenticator = 'externalbrowser',
warehouse = "<>",
database = "<>",
UID = "<>",
role = "<>"
)
DBI::dbAppendTable(con, name = DBI::Id(schema = "<>", table = "<>"), value = tmp[1:2,])
tmp was downloaded from Snowflake, the same table using RStudio: tmp 是从 Snowflake 下载的,使用 RStudio 的同一张表:
```{sql connection=con, output.var = 'tmp'}
select top 10 *
FROM <>
```
The error seems to be stemming from a VARIANT column where I store a JSON string.该错误似乎源于我存储 JSON 字符串的 VARIANT 列。
Error in new_result(connection@ptr, statement, immediate) : nanodbc/nanodbc.cpp:1374: 22000: SQL compilation error: Expression type does not match column data type, expecting VARIANT but got VARCHAR(2) for column FEATURES new_result(connection@ptr, statement,immediate) 中的错误:nanodbc/nanodbc.cpp:1374: 22000: SQL 编译错误:表达式类型与列数据类型不匹配,需要 VARIANT 但得到列 FEATURES 的 VARCHAR(2)
I had this once and it was an invalid JSON (missing brackets somewhere).我有过一次,它是一个无效的 JSON(某处缺少括号)。 Probably this helps.
可能这有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.