Segments
Define reusable semantic model filters for common business subsets.
Segments are predefined, reusable filters that package a boolean SQL-like predicate for use in queries and tooling. Instead of writing the same WHERE condition in every query, define it once as a segment and reference it by name. You can use the segments parameter within a semantic model to define segments.
For example, high-value accounts can be treated as a segment:
segments:
- name: high_value_accounts
expression: "{users.plan_type} IN ('pro', 'enterprise')"
description: Paid plan usersOr use a segment to implement cross-column OR logic:
segments:
- name: at_risk_users
expression: "{users.status} = 'active' AND {users.plan_type} = 'free'"
description: Free users who might churnParameters
Every field a segment supports, one section per key.
name
The identifier of a segment. Must be unique among measures and segments within a semantic model and follow the naming rules (^[a-zA-Z_][a-zA-Z0-9_]{0,63}$).
segments:
- name: high_value_accounts
expression: "{users.plan_type} IN ('pro', 'enterprise')"expression
A boolean SQL-like predicate, written with {name.column} references, that defines the subset of rows the segment matches. Required.
description
Human-readable explanation of what the segment represents. Optional; defaults to an empty string.
public
Controls whether the segment is exposed to consumers. Defaults to true.
tags
Categorization labels for the segment. Validated against ^[a-zA-Z0-9.:_-]+$ and normalized to lowercase.
terms
Business glossary references for the segment, typically dotted FQNs. Validated against ^[a-zA-Z0-9._-]+$ and normalized to lowercase.
ai_context
Structured hints for AI/LLM consumers on this segment: instructions, synonyms, caveats, and worked examples. See AI context for the full field reference.
Segments vs. dimension filters
Since segments are just predefined filters, it can be difficult to decide when to use a segment instead of filtering on a dimension directly. A filter on a dimension works better when the filter value changes a lot between queries, for example filtering users.plan_type = 'enterprise' ad hoc. A segment earns its keep when it packages a complex, reusable predicate that many queries share, such as the AND/OR combination in at_risk_users above.
Validation
SegmentSpec validates segment definitions during vulcan plan. It checks that:
nameandexpressionare both presentnameis unique among measures and segments within the semantic modelexpressionreferences only columns on the current semantic modelColumn references use the canonical
{model}.columnor barecolumnform, and the expression doesn't contain a subquery, CTE, lateral join, or column alias (logged as a warning by default; hard-fails whenstrict_semantic_validation: true)
Related pages
Semantic models for how a segment fits into the full spec
Measures for the aggregations segments commonly filter
Business metrics for applying segments to a metric
Last updated
Was this helpful?