Skip to content

Handle database tables? #107

@gadenbuie

Description

@gadenbuie

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions