dbWriteTable does not recognize objects that inherit from data.frame
cboettig opened this issue · 3 comments
vroom
now reads in tables as spec_tbl_df
objects. While dbWriteTable recognizes data.frame
and tibble classes, but spec_tbl_df
(which inherits from both tbl
and data.frame
not so much:
con <- DBI::dbConnect( duckdb::duckdb())
vroom::vroom_write(mtcars, "mtcars.csv")
cars <- vroom::vroom("mtcars.csv")
DBI::dbWriteTable(con, "mtcars", cars)
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function 'dbWriteTable' for signature '"duckdb_connection", "character", "spec_tbl_df"'
(note that the example is agnostic to database). cc @jimhester in case this is better addressed on the vroom side. I'm not entirely up to speed on S4 method signatures, but I guess maybe it's no surprise they don't respect s3-style inheritance? Why does this work for tbl
class? Is that handled manually?
This is a vroom issue it needs to use methods::setOldClass()
so S4 methods can see the S3 class hierarchy.
Fixed by tidyverse/vroom@f64a44b
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.