Summary
Extend value_mappings so that mapping values can be expressions, not just literals. This keeps value_mappings as the single declarative lookup mechanism while supporting cases where each branch needs computed output.
Current behavior
value_mappings maps literal keys to literal values:
slot_derivations:
visit_label:
populated_from: visit_code
value_mappings:
"1": "SCREENING"
"7": "BASELINE"
Proposed behavior
Mapping values can be either a literal string (unchanged) or an object with an expr field:
slot_derivations:
visit_id:
populated_from: visit_code
value_mappings:
"1":
expr: "uuid5({id} + 'SCREENING')"
"7":
expr: "uuid5({id} + 'BASELINE')"
Motivation
When each branch of a value mapping needs different computation (not just a different literal), users currently have to inline everything into a case() expression, which is unreadable for non-trivial mappings. This extension keeps the mapping table as a clean, auditable artifact while allowing computed results.
Design decisions
- Literal string values continue to work unchanged — no migration needed
- The
expr in a mapping value has access to the same bindings as a top-level expr (source fields, joins, etc.)
- No-match behavior: returns
None (unchanged from current value_mappings)
- This subsumes the unimplemented
expression_to_value_mappings field, which should be removed from the spec
Related
Summary
Extend
value_mappingsso that mapping values can be expressions, not just literals. This keepsvalue_mappingsas the single declarative lookup mechanism while supporting cases where each branch needs computed output.Current behavior
value_mappingsmaps literal keys to literal values:Proposed behavior
Mapping values can be either a literal string (unchanged) or an object with an
exprfield:Motivation
When each branch of a value mapping needs different computation (not just a different literal), users currently have to inline everything into a
case()expression, which is unreadable for non-trivial mappings. This extension keeps the mapping table as a clean, auditable artifact while allowing computed results.Design decisions
exprin a mapping value has access to the same bindings as a top-levelexpr(source fields, joins, etc.)None(unchanged from currentvalue_mappings)expression_to_value_mappingsfield, which should be removed from the specRelated
mapped()function and pipeline pattern — this is simpler)hide+slot()for cascading multi-stage patterns where the mapping result feeds into another expressionexpression_to_expression_mappingsdiscussion (concluded: usecase()instead)