Predicates¶
col() and lit() build the conditions a ColRule or a Check carries. Unlike a raw
pl.Expr, a predicate built this way survives a round trip through a spec
file — see Specs as files.
col¶
col
¶
A reference to a column, the starting point of every predicate.
Exactly the column named name: unlike pl.col, col("*") is the
column named *, not every column, and col("^id$") is not a regular
expression.
Examples:
lit¶
Pred¶
Pred
dataclass
¶
Base class of every predicate node. Build one with col().
Examples:
>>> pred = col("total").is_between(0, 100)
>>> isinstance(pred, Pred), pred
(True, col('total').is_between(0, 100))
>>> Check(pred, name="in_range").name
'in_range'
rename
¶
rename(mapping: Mapping[str, str]) -> Pred
The same predicate with its columns renamed by mapping.
Derived, so a node cannot be added that silently fails to rename -- which would leave a rule pointing at a column that no longer exists and only surface much later, as a spec failing its own validation.
is_between
¶
A predicate true where this value falls within [lower, upper].