Relation
A Relation defines how two models can be joined together.
Relations enable cross-model analysis by declaring the join conditions between models. This allows metrics to combine data from multiple models and enables the system to automatically generate the necessary SQL JOINs. The models involved in the relation are inferred from the condition.
Example
relations:
- name: orders_to_users
join_type: inner
condition: "${ref(orders).user_id} = ${ref(users).id}"
is_default: true
Attributes
Field | Type | Default | Description |
---|---|---|---|
path | string | None | A unique path to this object |
name | string | None | The unique name of the object across the entire project. |
file_path | string | None | The path to the file that contains the object definition. |
join_type | string | inner | Type of SQL join to use when connecting the models. |
condition | string | None | SQL condition for joining the models. Use ${ref(model).field} syntax to reference fields. Example: '${ref(orders).user_id} = ${ref(users).id}'. Cannot join on metrics (aggregated values). |
is_default | boolean | False | Whether this is the default relation to use when joining these two models. Useful when multiple relations exist between the same pair of models. |