-
Notifications
You must be signed in to change notification settings - Fork 0
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
Proposal: read with the same class that the object had on save #82
Comments
For |
The existing option is mainly for letting people opt out from I am not sure if we should restore the class, because we cannot be sure that we also restore type invariants. E.g. if somebody defines a nanoparquet is for reading and writing data frames. If you set the existing OTOH, maybe we could have an s3 generic that people could use to write out custom classes, or make |
Apologies for (possibly) submitting a support request disguised as an issue report, but I am failing to get the # Load nanoparquet
library(nanoparquet)
packageVersion("nanoparquet")
#> [1] '0.3.1.9000'
# Write a data.frame
d <- data.frame(letters)
f <- tempfile()
write_parquet(d, f)
# Read after setting options
options(nanoparquet.class = c("tbl_df", "tbl", "data.frame"))
read_parquet(f) |> class()
#> [1] "tbl" "data.frame"
# Read using explicit parquet_options()
read_parquet(f, options = parquet_options(class = c("tbl_df", "tbl", "data.frame"))) |> class()
#> [1] "tbl" "data.frame"
# Try alternative specifications
read_parquet(f, options = parquet_options(class = c("data.frame"))) |> class()
#> [1] "tbl" "data.frame"
read_parquet(f, options = parquet_options(class = character())) |> class()
#> [1] "tbl" "data.frame"
read_parquet(f, options = parquet_options(class = "tbl_df")) |> class()
#> [1] "tbl" "data.frame"
read_parquet(f, options = parquet_options(class = "")) |> class()
#> [1] "tbl" "data.frame" A few other somewhat related thoughts:
|
Currently,
parquet_options()$class
controls the class thatread_parquet()
assigns to the returned object. As a default, I feel it would be more natural to restore original the class from the time the object was saved (whicharrow
does). This would help integratenanoparquet
withtargets
as @hadley proposed in ropensci/targets#1311.The text was updated successfully, but these errors were encountered: