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

dbWriteTable does not recognize objects that inherit from data.frame #345

Closed
cboettig opened this issue Feb 3, 2021 · 3 comments
Closed

Comments

@cboettig
Copy link

cboettig commented Feb 3, 2021

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?

@jimhester
Copy link
Contributor

This is a vroom issue it needs to use methods::setOldClass() so S4 methods can see the S3 class hierarchy.

@jimhester
Copy link
Contributor

Fixed by tidyverse/vroom@f64a44b

jimhester added a commit to tidyverse/vroom that referenced this issue Feb 3, 2021
@github-actions
Copy link

github-actions bot commented Feb 4, 2022

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.

@github-actions github-actions bot locked and limited conversation to collaborators Feb 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants