File Structure
View Definition
Entity Definition
primary
: Main entity in this view (one per view)foreign
: Reference to entity in another view
Dimension Definition
string
: Text and categorical datanumber
: Numeric valuesdate
: Date values (YYYY-MM-DD)datetime
: Date and time valuesboolean
: True/false values
Measure Definition
count
: Count of recordssum
: Sum of valuesaverage
: Arithmetic meanmin
: Minimum valuemax
: Maximum valuecount_distinct
: Count unique valuesmedian
: Median valuecustom
: Custom SQL expression
Measure Filters
Topic Definition
Cross-View References
Reference dimensions or measures from related views using{{view.field}}
syntax:
Common Patterns
Basic Table View
SQL-Based View
View with Relationships
Filtered Measure
Dimension with Synonyms
Custom Calculation
Validation Checklist
- Each view has a unique name
- Each view has exactly one primary entity
- All foreign entities reference primary entities in other views
- All dimension
expr
values are valid SQL - Measure types match their expressions
- Cross-view references use correct syntax:
{{view.field}}
- Topic view references exist
- Datasource names match configuration
Common Errors
Missing Entity Key
Invalid Cross-View Reference
Missing Expression for Aggregation
Orphaned Foreign Entity
File Naming Conventions
- Views:
<name>.view.yml
(e.g.,orders.view.yml
) - Topics:
<name>.topic.yml
(e.g.,sales.topic.yml
) - Use lowercase with underscores for multi-word names
- Keep names descriptive and business-friendly
See Also
- Semantic Layer Guide - Complete documentation
- Agents - Using semantic layer with agents
- Context - Providing context to agents