@@ -26,32 +26,47 @@ read_register <- function(
2626 checkmate :: check_file_exists(path ),
2727 checkmate :: check_directory_exists(path )
2828 )
29+ check_parquet_path(path )
30+
31+ # If input path is a directory, read as partitioned Parquet register,
32+ # else read as Parquet file.
33+ if (fs :: is_dir(path )) {
34+ read_register_partition(path )
35+ } else {
36+ read_register_file(path )
37+ }
38+ }
39+
40+
41+ # ' Check whether path is to a Parquet file or directory with Parquet files.
42+ # '
43+ # ' @inheritParams read_register
44+ # '
45+ # ' @returns `path` invisibly.
46+ # '
47+ # ' @keywords internal
48+ # ' @noRd
49+ check_parquet_path <- function (path ) {
2950 if (
3051 fs :: is_dir(path ) &&
3152 length(fs :: dir_ls(path , regexp = " \\ .(parquet|parq)$" , recurse = TRUE )) ==
3253 0
3354 ) {
34- cli :: cli_abort(" The path {path} does not contain any Parquet files." )
55+ cli :: cli_abort(
56+ " The path {.path {path}} does not contain any Parquet files."
57+ )
3558 } else if (
3659 fs :: is_file(path ) &&
3760 fs :: path_ext(path ) != " parquet" &&
3861 fs :: path_ext(path ) != " parq"
3962 ) {
4063 cli :: cli_abort(
41- " The path {path} must have a `. parquet` or `. parq` extension."
64+ " The path {. path {path}} must have a {.val . parquet} or {.val . parq} extension."
4265 )
4366 }
44-
45- # If input path is a directory, read as partitioned Parquet register,
46- # else read as Parquet file.
47- if (fs :: is_dir(path )) {
48- read_register_partition(path )
49- } else {
50- read_register_file(path )
51- }
67+ invisible (path )
5268}
5369
54-
5570# ' Read a partitioned Parquet register as DuckDB table
5671# '
5772# ' @param path A character scalar with the path to the Parquet register
0 commit comments