You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can't understand how dplyr::copy_to() is implemented for this backend.
Partly related to #209.
It seems I cannot overwrite existing tables even if I tell duckdb to do so:
# overwrite = FALSE → should faildplyr::copy_to(
con_file,
tbl_faithful,
name="table",
overwrite=FALSE,
temporary=FALSE
)
#> Error in `db_compute()`:#> ! Can't copy query to table "table".#> Caused by error in `db_save_query.DBIConnection()`:#> ! Can't save query to table "table".#> ℹ Using SQL: CREATE TABLE "table" AS SELECT * FROM table2#> Caused by error in `duckdb_result()`:#> ! rapi_execute: Failed to run query#> Error: Catalog Error: Table with name "table" already exists!# overwrite = TRUE → should succeeddplyr::copy_to(
con_file,
tbl_faithful,
name="table",
overwrite=TRUE,
temporary=FALSE
)
#> Error in `db_compute()`:#> ! Can't copy query to table "table".#> Caused by error in `db_save_query.DBIConnection()`:#> ! Can't save query to table "table".#> ℹ Using SQL: CREATE TABLE "table" AS SELECT * FROM table2#> Caused by error in `duckdb_result()`:#> ! rapi_execute: Failed to run query#> Error: Catalog Error: Table with name "table" already exists!
The behavior changes with temporary tables (starting from scratch):
# it seems that `name` is ignored?# expected? as temp tables have different namestbl_mtcars_new<-dplyr::copy_to(
con_file,
tbl_faithful,
name="table",
overwrite=FALSE,
temporary=TRUE
)
tbl_mtcars_new#> # Source: table<"table"> [?? x 2]#> # Database: DuckDB v1.1.3-dev165 [user@Windows 10 x64:R 4.4.1/C:\Users\user\AppData\Local\Temp\RtmpE5CRQr\file40443b8c2184]#> eruptions waiting#> <dbl> <dbl>#> 1 3.6 79#> 2 1.8 54#> 3 3.33 74#> 4 2.28 62#> 5 4.53 85#> 6 2.88 55#> 7 4.7 88#> 8 3.6 85#> 9 1.95 51#> 10 4.35 85#> # ℹ more rows
# Forcing computation creates a temp table with another name:tbl_mtcars_new|>dplyr::compute()
#> # Source: table<dbplyr_4rRMAsZtXC> [?? x 2]#> # Database: DuckDB v1.1.3-dev165 [user@Windows 10 x64:R 4.4.1/C:\Users\user\AppData\Local\Temp\RtmpE5CRQr\file40443b8c2184]#> eruptions waiting#> <dbl> <dbl>#> 1 3.6 79#> 2 1.8 54#> 3 3.33 74#> 4 2.28 62#> 5 4.53 85#> 6 2.88 55#> 7 4.7 88#> 8 3.6 85#> 9 1.95 51#> 10 4.35 85#> # ℹ more rows# Now further calls fail dplyr::copy_to(
con_file,
tbl_faithful,
name="table",
overwrite=FALSE,
temporary=TRUE
)
#> Error in `db_compute()`:#> ! Can't copy query to table "table".#> Caused by error in `db_save_query.DBIConnection()`:#> ! Can't save query to table "table".#> ℹ Using SQL: CREATE TEMPORARY TABLE "table" AS SELECT * FROM table2#> Caused by error in `duckdb_result()`:#> ! rapi_execute: Failed to run query#> Error: Catalog Error: Table with name "table" already exists!# Even by forcing overwritingdplyr::copy_to(
con_file,
tbl_faithful,
name="table",
overwrite=TRUE,
temporary=TRUE
)
#> Error in `db_compute()`:#> ! Can't copy query to table "table".#> Caused by error in `db_save_query.DBIConnection()`:#> ! Can't save query to table "table".#> ℹ Using SQL: CREATE TEMPORARY TABLE "table" AS SELECT * FROM table2#> Caused by error in `duckdb_result()`:#> ! rapi_execute: Failed to run query#> Error: Catalog Error: Table with name "table" already exists!
I can't understand how
dplyr::copy_to()
is implemented for this backend.Partly related to #209.
It seems I cannot overwrite existing tables even if I tell duckdb to do so:
The fixture:
The issue:
Created on 2024-11-29 with reprex v2.1.1
The behavior changes with temporary tables (starting from scratch):
Created on 2024-11-29 with reprex v2.1.1
(I just wanted to write to duckdb from another lazy tbl without collecting.
With this bug, I had to
collect()
and useDBI::dbWriteTable()
.Am I misusing the dplyr interface?)
Using the latest versions from CRAN:
Thanks!
The text was updated successfully, but these errors were encountered: