What is a Semantic Model
Overview
A semantic model defines a business-friendly abstraction layer over physical database tables. It maps raw columns and joins into named dimensions, measures, time dimensions, and relationships that AI systems and analysts can reason about without understanding the underlying schema.
In Snowflake, semantic models are implemented as Semantic Views. Cortex Analyst and Cortex Agents consume these definitions to translate natural language questions into accurate SQL.
Why Semantic Models Matter for AI
Large language models cannot reliably generate SQL against raw schemas. Column names like amt_usd_net or cust_tier_cd are ambiguous without context. A semantic model solves this by providing:
- Business names and descriptions for every column
- Pre-defined metrics (revenue, churn rate, average order value)
- Relationships between tables (which foreign keys to join on)
- Filters and synonyms so the AI understands domain vocabulary
Without a semantic layer, AI-generated SQL is fragile and error-prone. With one, accuracy improves dramatically.
Semantic Layer vs Physical Layer
| Aspect | Physical Layer | Semantic Layer |
|---|---|---|
| Audience | Engineers, DBAs | Analysts, AI agents, business users |
| Naming | Technical column names | Business-friendly labels |
| Joins | Implicit via foreign keys | Explicitly declared relationships |
| Metrics | Computed ad-hoc in queries | Pre-defined and governed |
| Discoverability | Requires schema knowledge | Self-describing with descriptions |
| Governance | Column-level grants | Metric-level ownership and versioning |
Core Components of a Semantic Model
Dimensions
Categorical attributes used for grouping and filtering. Examples: region, product_category, customer_segment.
dimensions:
- name: region
expr: customer_region
description: "Geographic region of the customer"
synonyms:
- area
- territory
Measures
Quantitative values that are aggregated. Examples: total_revenue, order_count, average_order_value.
measures:
- name: total_revenue
expr: SUM(order_amount)
description: "Total revenue from completed orders"
default_aggregation: sum
Time Dimensions
Date or timestamp columns that enable time-based analysis.
time_dimensions:
- name: order_date
expr: order_created_at
description: "Date when the order was placed"
data_type: date
Relationships
Joins between tables declared explicitly so the AI knows how to combine data.
relationships:
- name: orders_to_customers
left_table: orders
right_table: customers
join_type: left_outer
relationship_columns:
- left_column: customer_id
right_column: id
How Cortex Analyst and Agents Use Semantic Models
User Question ──► Cortex Analyst ──► Reads Semantic View ──► Generates SQL ──► Returns Results
│
▼
Checks VQRs for
matching patterns
- The user asks a natural language question
- Cortex Analyst reads the semantic view definition (dimensions, measures, relationships)
- It matches the question to relevant tables, columns, and metrics
- If a Verified Query matches, it uses that as a template
- It generates and executes SQL, returning structured results
Cortex Agents extend this further by combining Analyst (SQL) with Cortex Search (unstructured data) and Python tools.
Business Context Metadata
Effective semantic models go beyond column mappings. They include:
- Descriptions on every dimension and measure explaining business meaning
- Synonyms so "revenue", "sales", and "income" all resolve correctly
- Sample values to help the AI understand data content
- Filters that define common business logic (e.g.,
is_active = TRUE)
dimensions:
- name: customer_segment
expr: segment_code
description: "Customer tier based on annual spend: Enterprise, Mid-Market, SMB"
synonyms:
- tier
- customer tier
- segment
sample_values:
- Enterprise
- Mid-Market
- SMB
Key Takeaways
- A semantic model bridges the gap between raw data and natural language understanding
- Snowflake implements semantic models as Semantic Views defined in YAML
- Core components are dimensions, measures, time dimensions, and relationships
- Rich metadata (descriptions, synonyms, sample values) is critical for AI accuracy
- Cortex Analyst and Cortex Agents rely on semantic views to generate correct SQL
Next Steps
Proceed to Building Semantic Views to create your first semantic view definition.