Building a semantic model for Snowflake Cortex Analyst takes time, but DataGalaxy already holds most of the pieces: the Business Glossary carries the business definitions, the Dictionary carries the logical column details, and Lineage shows which physical tables feed each concept.
What is left is connecting those pieces and filling the gaps Cortex Analyst needs — synonyms, join definitions and verified queries. The sections below cover the YAML structure Cortex Analyst expects and the order in which to fill it.
For a worked example, see Build a Snowflake Cortex Analyst Semantic Model for Finance.
What is a semantic model?
A semantic model bridges business language and technical data structures. It holds descriptions, synonyms, joins and query metadata so that natural language questions can be answered with SQL.
For Snowflake Cortex Analyst, the semantic model is defined in a YAML specification optimized for SQL-based star schemas.
What does a Cortex Analyst semantic model contain?
| Element | Description |
|---|---|
| Logical table | A view over a physical table with defined columns such as dimensions, time dimensions and measures |
| Physical table | An actual table in Snowflake |
| Logical column | Maps to a physical column or a derived field (for example, profit = revenue - cost) |
| Verified queries | Predefined SQL queries tied to natural language, for accuracy |
| Filters | Reusable filters (for example, currency IN ('USD', 'EUR')) |
| Joins | Supports left_outer, inner and other SQL join types |
What does the YAML file look like?
The template below shows every section a semantic model YAML file can hold.
name: <name>
description: <string>
# Define logical tables
tables:
- name: <name>
description: <string>
base_table:
database: <database>
schema: <schema>
table: <base table name>
dimensions:
- name: <name>
synonyms: <array of strings>
description: <string>
expr: <SQL expression>
data_type: <data type>
unique: <boolean>
time_dimensions:
- name: <name>
description: <string>
expr: <SQL expression>
data_type: <data type>
measures:
- name: <name>
description: <string>
expr: <SQL expression>
default_aggregation: <aggregate function>
data_type: <data type>
sample_values: <list of samples>
relationships:
- name: <string>
left_table: <string>
right_table: <string>
relationship_columns:
- left_column: <string>
right_column: <string>
join_type: <join_type>
relationship_type: <relationship_type>How do you build the semantic model?
- Create one model per Business Glossary universe, then extract its physical tables with Lineage and map the logical details from the Dictionary.
- Populate the logical tables from the Business Glossary, which supplies the dimensions, measures and descriptions, and derive the logical columns from the dictionary definitions.
- Define the joins. Use lineage to suggest join candidates, then set
join_type(for example,left_outerorinner) andrelationship_type(for example,many_to_one) by hand.
- Add verified SQL queries to improve query accuracy, and reusable filters that match your business needs.