-
Notifications
You must be signed in to change notification settings - Fork 43
Description
Package Version:
RPresto: 1.4.7
DBI: 1.2.3
dbplyr: 2.5.0
Issue 1
This is a similar issue to #275
When I ran
dplyr::copy_to(
conn,
some_remote_table,
name = in_schema('test', 'test_table')
)
I got an error
Error in vapply(x, unclass, character(1)) : values must be length 1,
but FUN(X[[1]]) result is length 0
The issue comes from the unconditional unname()
. Similar issue was also reported in dbplyr tidyverse/dbplyr#938
Lines 275 to 276 in 3013b53
.compute_tbl_presto <- function(x, name, temporary = FALSE, ..., cte = FALSE) { | |
name <- unname(name) |
Issue 1 Fix
I'm able to fix this by adding a conditional unname()
if (is_bare_character(x) || dbplyr::is.ident(x) || dbplyr::is.sql(x)) {
name <- unname(name)
Issue 2
After applying fix above, the compute
continues but outputs the table in connection schema, not the schema specified in in_schema
.
> dplyr::copy_to(
+ conn,
+ some_remote_table,
+ name = in_schema('test', 'test_table')
+ )
query FINISHED [============================================>----] 91% in 3s>
dbExistsTable(conn, in_schema("test", "test_table"))
[1] FALSE
> dbExistsTable(conn, in_schema("default", "test_table"))
[1] TRUE
Issue 2 Fix
The issue comes from sqlCreateTableAs
calls dbplyr_table_path
to get target table name. The function dbplyr_table_path
returns the last component of the table path (i.e. the name of the table). So the schema name is omitted. I was able to fix it by removing table_path_name
call.
Lines 34 to 35 in 3013b53
if (inherits(name, "dbplyr_table_path")) { # dbplyr >= 2.5.0 | |
name <- dbplyr::table_path_name(name, con) |
I'm happy to start a PR.