File Structure
Global Semantics
Global semantics allow reusable definitions inglobals/semantics.yml:
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
Default Filters
Apply filters automatically to all queries in a topic:- Multi-tenancy (filter by tenant/org)
- Data governance (restrict to specific subsets)
- Active records only (exclude soft-deleted)
- Time-based defaults (recent data only)
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
Topic with Default Filters
Topic with Date Range Filter
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
exprvalues are valid SQL - Measure types match their expressions
- Cross-view references use correct syntax:
{{view.field}} - Topic view references exist
- Datasource names match configuration
- Default filter fields reference valid dimensions in topic views
- Default filter operators match field data types
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