Skip to contents

Opens a large dataset as one or more lazy DuckDB tables. No observations enter R memory until the query is explicitly collected with dplyr::collect(). Related tables returned in the same catalog share one database connection and can be joined with standard dplyr verbs.

Usage

query_dataset(name, table = NULL, version = "latest", quiet = FALSE)

Arguments

name

Character. Dataset identifier. See list_datasets() for datasets whose access_mode is "query".

table

Character or NULL. Return one table when supplied. When NULL, return a named catalog containing every related table.

version

Character. Immutable dataset version, or "latest" to use the version referenced by the latest manifest.

quiet

Logical. If TRUE, suppress informational messages.

Value

If table is supplied, a closable lazy dbplyr table. Otherwise, a realestatebr_query_dataset catalog containing named lazy tables. Close either result explicitly with close() when it is no longer needed.

See also

get_dataset() for datasets returned directly in memory.

Examples

if (FALSE) { # interactive()
cno <- query_dataset("cno")
on.exit(close(cno))

constructions_sp <- cno$constructions |>
  dplyr::filter(.data$state == "SP")

result <- constructions_sp |>
  dplyr::inner_join(cno$areas, by = "cno") |>
  dplyr::collect()
}