name: op-attr-formula
description: Per-row expression evaluation against the record's fields via expr-lang.
kind: operator
category: ATTR
operator: ATTR_FORMULA
type: reference
applies_to: process, compose, predict
examples_tags: [feature-engineering, streaming-friendly]
Use when
Adds a number to every row computed from the row’s own fields with an expression, such as price * qty.
Questions it answers:
- What is each order’s line total from its price and quantity?
- Which rows meet a combined rule, as a 0/1 field for counting?
Use something else:
FILTER_EXPRESSIONwhen you want to keep or drop rows by a rule rather than add a field.FEAT_LOGwhen you want the logarithm of a field.
Params
| Name | Type | Default | Description |
|---|---|---|---|
expression | string | (required) | expr-lang/expr text, evaluated per row. |
Inputs
field— unreadlabel— derived field name; defaultATTR_FORMULA_
Output
One float64 per record (bools → 1.0 / 0.0); a nil result → null (n_null; predict: PULSE_ADVISORY_FORMULA_NULLABLE_RESULT). x * 2 on a null x → PROCESSING_RUNTIME (predict: PULSE_ADVISORY_FORMULA_NULLABLE_OPERAND); use x ?? 0.
Contract
- Types: any type.
- Weight: not read; a weight in force is skipped.
- Streaming: streamable.
Gotchas
- Reads schema fields and EARLIER attribute labels (declared order); stage across requests via compose or a process chain.
total(expr)(this operator only): the post-filter cohort sum on every row (x * 1000 / total(x)); two-pass, frequency weights only. Detail and refusals:formula-totals.- The text goes in the
expressionslot;params.expression→PULSE_REQUEST_UNKNOWN_FIELD; an empty slot isPROCESSING_CONFIG. income * params.ratereads the request constant"params": {"rate": 1.1}(request-params).- Bad syntax / names / types →
PULSE_FORMULA_COMPILE_ERRORon predict and at build (details.compile_error). decimal128is exact (decimal-formulas); the output takes the nearest f64. A baredatetimeinweekday/month_index/date_truncfails compile: wrap it into_day(calendar-formulas).- A literal
coef("m", …)of a compose fit that failed on its data: null on every row +PULSE_FIT_UNAVAILABLE{fit, attribute, code}; a non-literal fit name reaching it is refused with the fit’s code.
See
pulse_examples_search tags=[feature-engineering]- Skills:
formula-totals,attribute-composition,expression-language(functions, binding,lookup(...)),decimal-formulas,calendar-formulas