QC-14: Check row count bounds and optional file size
Source:R/checks_generic.R
check_min_row_count.RdRuns up to four sub-checks, each returning a separate
dq_result:
Empty file – FAIL when the file contains no data rows at all. Emitted unconditionally (independent of
min_row_count) so that an empty delivery always fails the run.File size – only when
file_pathis supplied andmax_file_size_mbis configured inrules: FAIL if the file exceeds the size limit.Minimum row count – FAIL if
row_count < min_row_count. Skipped (PASS with a note) whenmin_row_countis0.Maximum row count – only when
max_row_countis configured inrules: FAIL ifrow_count > max_row_count.
Arguments
- df
A data frame with all columns as character vectors (as returned by
read_dataset).- config
Named list. Merged configuration as returned by
load_config.- file_path
Character or
NULL. Absolute path to the file on disk, required for the optional file-size sub-check.
Value
A list of dq_result objects (one to four entries
depending on which sub-checks are active).
Examples
cfg_dir <- system.file("demonstrations/config", package = "dqcheckr")
cfg <- load_config("starwars_csv", config_dir = cfg_dir)
path <- system.file("demonstrations/data/starwars.csv", package = "dqcheckr")
df <- read_dataset(path, cfg)
check_min_row_count(df, cfg, file_path = path)
#> [[1]]
#> [[1]]$check_id
#> [1] "QC-14"
#>
#> [[1]]$check_name
#> [1] "Minimum row count"
#>
#> [[1]]$column
#> [1] NA
#>
#> [[1]]$status
#> [1] "PASS"
#>
#> [[1]]$observed
#> [1] "87 rows"
#>
#> [[1]]$threshold
#> [1] "80 rows minimum"
#>
#> [[1]]$message
#> [1] "File has 87 rows, meeting the minimum of 80."
#>
#>