Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy_to(overwrite=TRUE) not working in duckdb and dbplyr #1535

Open
arthurgailes opened this issue Aug 14, 2024 · 0 comments
Open

copy_to(overwrite=TRUE) not working in duckdb and dbplyr #1535

arthurgailes opened this issue Aug 14, 2024 · 0 comments

Comments

@arthurgailes
Copy link

It works fine for a dataframe, but not for a lazy_tbl.

library(duckdb)
#> Loading required package: DBI
library(dplyr)
#> Warning: package 'dplyr' was built under R version 4.2.3
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
con <- dbConnect(duckdb())

copy_to(con, mtcars, "mtcars", temporary = FALSE)
copy_to(con, mtcars, "mtcars", overwrite = TRUE, temporary = FALSE)

mtcars_sql <- tbl(con, "mtcars")

copy_to(con, mtcars_sql, "mtcars2", temporary = FALSE)
copy_to(con, mtcars_sql, "mtcars2", overwrite = TRUE, temporary = FALSE)
#> Error in `db_compute()`:
#> ! Can't copy query to table mtcars2.
#> Caused by error in `db_save_query.DBIConnection()`:
#> ! Can't save query to table mtcars2.
#> ℹ Using SQL: CREATE TABLE mtcars2 AS SELECT * FROM mtcars
#> Caused by error:
#> ! rapi_execute: Failed to run query
#> Error: Catalog Error: Table with name "mtcars2" already exists!

dbDisconnect(con)

Created on 2024-08-14 with reprex v2.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant