Repository navigation
This release adds two things a spec couldn't say before: which rows a class derivation applies to, and what a slot should hold when its source value is missing or unmapped. Both came out of getting BDC output to validate against BDCHM. Nothing changes for a spec that doesn't use them.
Filtering rows
A class derivation maps every row of its table. filter_rows is an expression evaluated on each source row, and a row where it isn't true yields no object: no record at the top level, and no nested object under a slot. (#407)
class_derivations:
Visit:
populated_from: exams
filter_rows: "{exam} == 1"
slot_derivations:
id:
expr: "{pid} + ':exam1'"- It reads joined tables like any expression (
{people.cohort} == "original"). - A filter that evaluates to None rejects the row, so an ordering comparison on an empty cell (
{exam} >= 1) drops it.==and!=compare None like any other value, so{exam} != 2keeps rows whereexamis empty; guard with{exam} is not None and ...to drop them. - It runs before any slot is derived, so calling
slot()in a filter is an error. It also runs before apivot_operation. - A filter that fails to evaluate is a row error, reported like a slot error.
validate-specchecks the names a filter reads, andmap-datalogs a warning when a filter keeps none of the rows it saw. That can be correct on a subset of a study, so it never fails the run, even under--strict.
See Filtering Rows.
Filling missing and unmapped values
Two SlotDerivation fields fill a populated_from slot that would otherwise come out null. (#408)
value_if_missing: used when the source value is missing, meaning an empty cell, an absent column, or a code nulled bymissing_values.value_if_unmapped: used when a present value matches no key invalue_mappingsorexpression_mappings.
condition_status:
populated_from: phv00203303
value_mappings:
'0': ABSENT
'1': PRESENT
value_if_missing: UNKNOWN
value_if_unmapped: UNKNOWN- The fill is a target value. It goes through the same range coercion and enum resolution as a mapped value, but
value_mappingsandoffsetaren't applied to it. validate-specchecks both fills against the target enum, likevalue_mappingsvalues.- They apply only to
populated_fromslots, likemissing_values.
Known issues
- A
value_mappingsresult, or one of the new fills, comes out null when the source slot's range is an enum that has an enum derivation. (#413) - Under
--unrestricted-eval, afilter_rowsthat fails to evaluate rejects the row instead of raising. The "kept none of N rows" warning is the only signal.
Full changelog: v0.6.0...v0.6.1