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

check column availability before reading #281

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions R/fst.R
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@ read_fst <- function(path, columns = NULL, from = 1, to = NULL, as.data.table =
if (!is.character(columns)) {
stop("Parameter 'columns' should be a character vector of column names.")
}

# check if any requested 'columns' are not present in the 'path'
file_cols = metadata_fst(path)$columnNames
miss_cols = setdiff(columns, file_cols)

if (length(miss_cols) > 0) {
stop("Parameter 'columns' should name columns in the file stored at 'path'. These columns are not in that file: ",
paste(miss_cols, collapse = ", "))
}

}

if (!is.numeric(from) || from < 1 || length(from) != 1) {
Expand Down