Skip to main content
A semantic view is a business-level description of a part of your warehouse: which tables belong to a domain, how they join, what counts as a metric or a dimension, and what business names people actually use for them. Without such an object that knowledge lives outside the database — in a BI semantic layer, a dbt project, or a hand-maintained prompt — so every consumer re-implements the same join topology and the same metric definitions, and they drift apart. A plain logical view does not close the gap either: it can pre-join tables, but it cannot expose metrics as reusable aggregates, it cannot carry the synonyms, comments and sample values an AI needs for grounding, and it fixes the join shape and the grain at definition time. A semantic view holds no data. When a query references it, it is inlined into the surrounding SQL as a derived subquery built from its RELATIONSHIPS — with only the joins and the aggregation that the query actually asks for. This page is the task-oriented tour and the behavioural contract. The full syntax lives in CREATE SEMANTIC VIEW and Querying Semantic Views.

Quick start

Step 1. Define the model

Step 2. Query it by business name

The join is the model’s job, not the query’s:

Step 3. Verify before you trust it

Then run the original SQL and the semantic-view query and compare the rows. A model is worth exactly as much as that comparison.

Step 4. Manage it

Definition clauses at a glance

Rules enforced when the view is created

Each rule exists because breaking it produces a wrong number rather than an error. They are checked at CREATE time — the only place where the cost of getting it wrong is a failed statement instead of a report nobody questions. The checks live in the analyzer, so the SQL path and the REST/YAML path are governed by the same rules.

Rule 1 in practice: when the dimension has no key

Do not declare a key that is not there — the engine believes the declaration. Expose the table through a logical view that establishes one, and use that view as the base table:
Then verify the claim before relying on it:
Accepted uniqueness evidence: ASOF and BETWEEN relationships are exempt from this rule.

Rule 2 in practice: one view per snowflake

TPC-H and SSB are single snowflakes, rooted at lineitem and lineorder. TPC-DS is not: its six sales and returns tables are six roots that merely share the dimension tables, so it needs one semantic view per channel.

Choosing the join type per relationship

Real snowflakes are not uniform. The relationship from a fact to a mandatory dimension is an inner join — the row cannot exist without it — while the relationship to an optional dimension must stay a left join or rows disappear.
A pinned join type is stored with the relationship, so it survives a restart, is echoed by SHOW CREATE SEMANTIC VIEW, and round-trips through the YAML API as join_type. A relationship can also match on time rather than on equality. Several equal-join columns may be combined with at most one ASOF or BETWEEN column, and the two cannot appear in the same relationship — there the match rule, not key uniqueness, decides the grain. See CREATE SEMANTIC VIEW for the syntax.

What a base table may be

A base object only has to expose a column list for the FACTS / DIMENSIONS / METRICS expressions to resolve against, so a logical view works wherever a table does — on the fact side, on the dimension side with auto-resolved join keys, when the view already aggregates, across databases, and even when the view is itself defined over a semantic view. That is what makes a model expressible when the raw tables are not shaped like a star: sink the de-duplication, the one-sided filter or the expression join key into a logical view, and let the semantic view reference it.

Querying: two forms

Normative rules for the two forms: A second form, a plain table-style reference, exposes the view’s flat columns; see Style 2. Several accesses of the same or different semantic views may appear in one query — self-joins, UNION ALL, CTEs and sub-queries all work, which is what period-over-period reporting needs.

Behaviour you can rely on

Only the tables a query needs are joined

The inlined SQL joins the smallest connected set of tables covering what the query projects and filters on, plus whatever is needed to connect them. This matters for results, not only for speed. A customer asked ā€œhow many power stations are thereā€ over a view that also modelled devices; with every table joined, each station row was multiplied by its device count and the count came back as the number of devices. Two consequences to design for:
  • Reference declared facts, dimensions and metrics rather than base-table columns. A predicate naming a base-table column directly (WHERE o_orderstatus = 'F') skips pruning, because the model alone does not say which table owns that column.
  • A relationship you rely on as a filter is only joined when the query references it. If an inner join is meant to drop non-matching rows, expose a field of that table and name it in the query; otherwise the filter disappears together with the pruned branch.

A restated filter is not applied twice

A query that restates a conjunct of the view’s FILTER in its own WHERE does not get that predicate applied twice: repeated top-level AND conjuncts are dropped from the inlined WHERE. This matters for generated SQL, which routinely restates the model’s filter.

Session variables

Privileges

DDL issued against a follower FE is forwarded to the leader, so semantic views can be created and dropped from any FE.

Inspecting a model and a query

EXPLAIN SNOWFLAKE reports cases metadata cannot decide as explicit assumptions rather than silently accepting them, and raises an error when the topology cannot be a snowflake — neither side of an equal join unique, several independent snowflakes, an ON clause with no join key, or an ASOF-shaped edge pointing at a side that is not unique. EXPLAIN LINEAGE exists so that a tool does not have to re-implement a partial SQL parser outside the server to answer ā€œcan this query be expressed as a semantic viewā€. It is emitted as JSON by default and as a PlantUML mindmap with TEXT.

Grounding for AI and BI

Definitions can also be managed over REST, as the database native YAML or OSI Core Metadata Spec YAML — see Semantic View YAML REST API.

See also

Persistent staging views

TEMPORARY marks a semantic view as staging (not published). It is persisted across restarts and is not tied to a session. Users with the required privileges can still query it by name. Applications can use the flag to control AI-agent discovery; it is not an access-control boundary. SHOW SEMANTIC VIEWS lists published views. SHOW ALL SEMANTIC VIEWS lists both states; SHOW TEMPORARY SEMANTIC VIEWS lists staging views. The Temporary column distinguishes them. A named SHOW SEMANTIC VIEW can inspect either state. Use SET TEMPORARY = TRUE or FALSE to change state. A rename can change the state atomically. SWAP WITH exchanges names while each object retains its staging state. SHOW CREATE reflects the current name and state. Existing views without the persisted flag remain published (false).

Query semantic metadata with SQL

The internal catalog exposes six virtual tables in information_schema: Each table below lists its complete schema. List-valued attributes use JSON text, not SQL ARRAY values.

semantic_views

One row per visible semantic view.

semantic_tables

One row per declared source table.

semantic_relationships

One row per declared relationship.

semantic_dimensions

One row per declared dimension.
The three semantic-column tables share this schema. Attributes not declared for a column retain the SHOW defaults: empty strings, empty JSON arrays or false, as appropriate.

semantic_facts

One row per declared fact.
The three semantic-column tables share this schema. Attributes not declared for a column retain the SHOW defaults: empty strings, empty JSON arrays or false, as appropriate.

semantic_metrics

One row per declared metric.
The three semantic-column tables share this schema. Attributes not declared for a column retain the SHOW defaults: empty strings, empty JSON arrays or false, as appropriate. Every row carries SEMANTIC_VIEW_CATALOG, SEMANTIC_VIEW_SCHEMA and SEMANTIC_VIEW_NAME for its owning SV. Source table identities in semantic_tables use TABLE_CATALOG, TABLE_SCHEMA and TABLE_NAME. Collection-valued attributes are JSON text. Unavailable view/table/relationship scalar fields are SQL NULL; semantic column attributes retain the existing SHOW empty-string defaults. Creation time is a DATETIME when available; application-specific creators, update times and versions can remain in an ordinary business table. If a legacy stored DDL batch cannot safely be mapped to one SV, DEFINITION is NULL while the other metadata remains queryable. Quote SQL keyword column names with backticks, for example `AI_SQL_GENERATION`, `AI_QUESTION_CATEGORIZATION` and `WINDOW`. Unlike the default SHOW list, semantic_views includes both published and staging objects. Filter TEMPORARY explicitly when selecting models for an AI agent. Access follows the existing semantic-view privileges. Equality filters on the owning catalog, schema and SV name are applied in FE before expanding definitions, including when a BE scanner is used. Staging filters are also forwarded when recognized. Other SQL predicates, joins, ordering and limits retain their normal SQL semantics. Metadata is read with a short list snapshot and individual object locks; this is not a transactionally consistent snapshot of all objects during concurrent DDL. SHOW SEMANTIC TABLES FROM <sv> and SHOW SEMANTIC RELATIONSHIPS FROM <sv> expose the corresponding definitions. Existing SHOW FACTS, DIMENSIONS and METRICS use the same stored definitions and column-attribute model.