Semantic DomainsTemplate Authoring
Validation & Examples
Complete domain example and validation error reference
Complete Example: E-Commerce Domain
Here's a complete domain template combining all concepts -- 3 datasets, 3 relationships, nested calculated metrics, calculated dimensions, and a grain mapping:
Validation Errors
When you save a domain template, Semaphor validates it and reports errors. Here are the validation codes you may encounter:
Errors
| Code | Meaning | Fix |
|---|---|---|
| E001 | Circular dependency detected (e.g., metric A references B which references A) | Break the cycle by removing one of the references |
| E002 | Input references an unknown metric name | Check that the referenced metric exists in calculatedMetrics |
| E003 | Input references an unknown field in a dataset | Verify the dataset has that field in its field lists |
| E004 | Input references an unknown dataset name | Ensure the dataset is defined in the datasets array |
| E005 | Token {name} in expression not found in inputs | Add the missing token name to the inputs map |
| E007 | Calculated dimension references a metric | Dimensions can only reference columns or other dimensions |
| E008 | Invalid filter on a metric | Check filter syntax (field + operator + value) |
| E009 | Invalid expression syntax | Remove braces inside string literals |
| E010 | Input requires an aggregate but none specified | Add aggregate to the input or wrap token in aggregate function |
| E011 | Input references an unknown calculated dimension | Check that the dimension exists in calculatedDimensions |
| E012 | Unknown field reference in metric expression | Check spelling of field names in the expression; ensure the referenced field is defined in the dataset |
| E013 | Invalid metric expression | Review expression for circular dependencies, remove AS aliases, and check SQL syntax |
Warnings
| Code | Meaning | Action |
|---|---|---|
| E006 | Input is defined but not used in expression | Remove the unused input or add it to the expression |
| W001 | Dataset has no primary key signal | Add primaryKey or mark identifier as type: primary |
| W002 | Relationship may cause metric inflation | Consider using aggregate_then_join strategy or review cardinality |
Next Steps
- Agent Guide -- Build templates programmatically with validation rules
- User Guide -- How end users interact with your domain in dashboards