Skip to contents

Explicitly execute a date-quality audit on a scoped lazy ClickHouse query or local data frame. No conversion or format guessing is performed: use the raw and converted columns retained by [thip_table()]. Supports dates and datetimes.

Usage

thip_date_audit(data, columns, by = character())

Arguments

data

A lazy ClickHouse table or local data frame.

columns

Named character vector `converted_column = "raw_column"`.

by

Optional character vector of grouping columns, such as source table.

Value

A local data frame with one row per group and field: `field`, `raw_column`, `n_total`, `n_missing` (raw NA/NULL), `n_blank` (empty or whitespace-only text), `n_parsed` (nonblank raw, nonmissing converted), `n_failed` (nonblank raw, missing converted), and `n_inconsistent` (missing/blank raw but nonmissing converted). The first four categories missing, blank, parsed and failed partition n_total. Inconsistency overlaps missing/blank and indicates the supplied pair needs checking.

Details

This executes aggregate SELECT queries, one per field, on remote data; it does not retrieve individual records or write database objects. Scope data before calling, preferably without filtering on converted dates: that would remove the parsing failures you want to detect. Grouping by a person identifier would expose person-level summaries; use source metadata. No implicit sampling or row limit is applied. Auditing can scan the selected source once per field. Empty ungrouped input returns zero counts; empty grouped input has no groups. Existing dplyr grouping is ignored; use by. A nonmissing converted value does not prove correct calendar interpretation, clinical plausibility, or source completeness. Local converted columns must be Date or POSIXct; remote pairs should come from thip_table conversions.