Skip to content

Commit

Permalink
using custm arrow_open_dataset to detect when parquet file is corrupted
Browse files Browse the repository at this point in the history
  • Loading branch information
rafapereirabr committed Feb 1, 2025
1 parent 6d5cb27 commit 4f37227
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion R/match_cases.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ match_cases <- function(con,
# Load CNEFE data and write to DuckDB
# filter cnefe to include only states and municipalities
# present in the input table, reducing the search scope
filtered_cnefe <- arrow::open_dataset( path_to_parquet ) |>
filtered_cnefe <- arrow_open_dataset( path_to_parquet ) |>
dplyr::filter(estado %in% input_states) |>
dplyr::filter(municipio %in% input_municipio) |>
dplyr::compute()
Expand Down
2 changes: 1 addition & 1 deletion R/match_weighted_cases.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ match_weighted_cases <- function(con,
# Load CNEFE data and write to DuckDB
# filter cnefe to include only states and municipalities
# present in the input table, reducing the search scope
filtered_cnefe <- arrow::open_dataset( path_to_parquet ) |>
filtered_cnefe <- arrow_open_dataset( path_to_parquet ) |>
dplyr::filter(estado %in% input_states) |>
dplyr::filter(municipio %in% input_municipio) |>
dplyr::compute()
Expand Down
4 changes: 2 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ arrow_open_dataset <- function(filename){
arrow::open_dataset(filename),
error = function(e){
msg <- paste(
"File cached locally seems to be corrupted. Please download it again using 'cache = FALSE'.",
sprintf("Alternatively, you can remove the corrupted file with 'geocodebr::geocodebr_cache(delete_file = \"%s\")'", basename(filename)),
"Arquivo local possivelmente corrompido. ",
"Apague os arquivos do cache com 'geocodebr::deletar_pasta_cache()' e tente novamente.",
sep = "\n"
)
stop(msg)
Expand Down

0 comments on commit 4f37227

Please sign in to comment.