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

Handle database tables? #107

Open
gadenbuie opened this issue Dec 15, 2021 · 0 comments
Open

Handle database tables? #107

gadenbuie opened this issue Dec 15, 2021 · 0 comments

Comments

@gadenbuie
Copy link
Member

gadenbuie commented Dec 15, 2021

Maybe tblcheck should include some special handling for remote database tables. Here's a smaller example based on the Introduction to dbplyr • dbplyr:

library(dplyr)
con <- DBI::dbConnect(RSQLite::SQLite(), dbname = ":memory:")

copy_to(con, nycflights13::flights[1:100, ], "flights",
        temporary = FALSE, 
        indexes = list(
          c("year", "month", "day"), 
          "carrier", 
          "tailnum",
          "dest"
        )
)

Given a remote database table, flights_db, tbl_grade() errors because the expected object is not a data.frame.

flights_db <- tbl(con, "flights")

tblcheck::tbl_grade(flights_db, flights_db)
#> An error occurred in the grading code: Assertion on 'expected' failed: Must be of type 'data.frame', not 'tbl_SQLiteConnection/tbl_dbi/tbl_sql/tbl_lazy/tbl'.
#> <gradethis_graded: [Neutral]
#>   Uh-oh! We can't provide feedback at this time. Don't worry, it's not
#>   your fault! There's an issue behind-the-scenes with this exercise.
#> >

For now authors can collect(.result) and collect(.solution), but maybe tbl_grade() could handle this automatically. Alternatively, we could think about rendering the lazy tbl to SQL or doing something else to avoid having to collect the complete data...

flights <- collect(flights_db)
tblcheck::tbl_grade(flights, flights)
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