Returns the baseline column schema for an OpenAlex entity (used by
pro_request_parquet(schema = "auto") to resolve ambiguous
DuckDB JSON types), and optionally refreshes the user-level cache from a
local Parquet corpus.
Usage
oa_schema(
entity = NULL,
parquet_dir = NULL,
entities = "all",
overwrite = FALSE,
update = FALSE,
verbose = TRUE
)Arguments
- entity
Character scalar. Entity name, e.g.
"works". Required whenupdate = FALSE; ignored whenupdate = TRUEandentities != "all"is a vector.- parquet_dir
Character scalar. Root Parquet directory containing one sub-directory per entity, e.g.
"/Volumes/openalex/parquet". Required whenupdate = TRUE; ignored otherwise.- entities
Character vector or
"all"(default). Entities to refresh whenupdate = TRUE."all"auto-discovers sub-directories ofparquet_dir, excluding*_awsstaging directories.- overwrite
Logical. When
update = TRUE, overwrite an existing cached CSV? DefaultFALSE.- update
Logical. When
TRUE, read schema fromparquet_dirand write to the user cache. DefaultFALSE.- verbose
Logical. Print progress messages? Default
TRUE.
Value
update = FALSE: a data.frame with columns col_name
and col_type, or NULL if no schema is found for
entity.update = TRUE: the path to the schemata cache directory
(invisibly).
Resolution order (update = FALSE)
User cache (
tools::R_user_dir("openalexPro","cache")/schemata/<entity>.csv)Schemas bundled with the package (
inst/extdata/schemata/<entity>.csv)
Refreshing the cache (update = TRUE)
Reads the schema of each entity corpus from parquet_dir using
DuckDB and writes the result to the user cache. After updating, the new
schema is available to subsequent calls with update = FALSE and to
pro_request_parquet(schema = "auto"). Run periodically to pick up
new fields added by OpenAlex.
See also
pro_request_parquet for the schema parameter.