Skip to contents

Runs the query the first time and writes the result to a parquet cache keyed on the query's SQL; later calls with the same query read the cache instead of re-scanning the lake. Big pulls page in slowly, so caching makes iterating on an analysis fast.

Usage

collect_cached(
  query,
  refresh = FALSE,
  dir = getOption("ckdata.cache_dir", ".ckdata-cache")
)

Arguments

query

A lazy dbplyr query — typically a lake_tbl() piped through dplyr verbs, e.g. lake_tbl("mart_responses") |> filter(...).

refresh

If TRUE, ignore any cached result and re-run the query.

dir

Cache directory; defaults to the ckdata.cache_dir option, or ".ckdata-cache".

Value

A tibble of results.

Details

The cache is keyed on the query only, NOT on the data — the lake rebuilds nightly, so a cache made before a rebuild is stale. Pass refresh = TRUE (or delete the cache directory) to re-pull.