Skip to contents

Copies every row of the persons with MOD(person_id, sample_modulus) = sample_remainder from person, observation_period, visit_occurrence, condition_occurrence, drug_exposure and measurement, plus the concept_ancestor rows their events need. The database starts from the package's empty CDM schema (build_schema()), so a table the source lacks (SynPUF has no visit_occurrence or measurement) stays empty, as its stand-in does on BigQuery. The cohort and features are per person, so run_duckdb_demo() on the copy must give exactly the BigQuery demo_cohort / demo_features rows for the same persons. Each query scans its source table once (BigQuery bills the columns read, whatever the sample size); the copy itself is small. Ids are kept exact (integer64 on download, BIGINT in DuckDB).

Usage

copy_demo_sample_from_bigquery(
  billing_project,
  dataset = .DEMO_PUBLIC_DATASET,
  db_path,
  sample_modulus = 1000L,
  sample_remainder = 0L,
  runner = NULL
)

Arguments

billing_project

Your GCP project id.

dataset

Source CDM, "project.dataset".

db_path

DuckDB file to write: a new file, or one holding only an earlier copy (copied tables are replaced).

sample_modulus, sample_remainder

Which persons to copy.

runner

For tests: a list with fetch(sql) returning a data frame.

Value

Invisibly, a data frame of table names and copied row counts (tables missing from the source are not listed).