Feature
A feature is a queryable, row-grain attribute of an entity — a column, a derivation, or a value pulled across a relationship.
A queryable, row-grain attribute of an entity — a column, a derivation, or a value pulled across a relationship.
What it is
Features answer "what is this attribute?" at the entity's grain — one value per entity instance. Use a feature for row-level values; use a metric when you need an aggregation across rows.
A feature's sql can be a direct column read, a formula over other features, a function call, or a value pulled from a related entity. The expression follows the SQL expressions grammar — segment-counted paths, metric() / first() / last(), and the join-binding rule.
Where it lives
.lynk/domains/<domain>/entities/<entity>/schema.yml, under features:.
Format
For any ratio, state the scale (0–1 vs 0–100) in the description, and keep every threshold in that scale — a 0–1 value compared against >= 55 is always false, and nothing errors.
name
✓
string
Unique within the entity across features, metrics, and relationships.
description
✓
string
Load-bearing — the agent reasons from it, so the sql must produce exactly what it describes.
data_type
✓
number | string | datetime | boolean
The type of the resulting value.
join_name
conditional
string
A relationship name. Required unless sql/filter reference only the entity's own identity source and/or its own features — you never need a join_name to "join" an entity to itself. Anything reached through a relationship needs one.
filter
–
SQL predicate
A WHERE clause that narrows source rows before the sql evaluates. Grain-preserving.
The full rule for when join_name is required, and how one join_name binds every cross-entity reference in the expression, lives in SQL expressions → join binding.
Examples
A formula over the entity's own features. No join_name: every reference is local.
A value pulled across a relationship, combined with a metric. On Grove's customer, the latest subscription's MRR as a share of the customer's total.
A few more shapes, for reference:
Validation
nameis unique within the entity (features, metrics, and relationships share one namespace).The
sqlcomputes what thedescriptionsays, and the feature compiles and field-probes at the Lynk build — the authoritative surface where every column must resolve to real data. A raw-warehouse check alone is a proxy; fabricated values or columns fail the build.data_typeis one ofnumber,string,datetime,boolean.join_nameis required unlesssql/filterreference only the entity's own identity source and/or own features; a missing requiredjoin_namefails.Every reference in
sql/filteris reachable through the declaredjoin_name(the local entity plus the join's steps); what each relationship type exposes is the SQL expressions → join binding rule.Grammar errors are detailed in SQL expressions → validation.
Related
Parent: schema.yml · Entity
Siblings: Metric · Relationships
SQL expressions — the
sqlgrammar and join bindingLynk SQL — how features appear as columns at query time
Last updated