Overview of semantic views

You can store semantic models (for use by Cortex Analyst) as Snowflake objects in a database schema. These Snowflake objects are semantic views and are schema-level objects that correspond to semantic models.

To create and manage semantic views, you can use SQL commands (such as CREATE SEMANTIC VIEW) and the Cortex Analyst Semantic View Generator, which is a wizard in Snowsight that guides you through the process of creating a semantic view.

Note

Semantic views are considered metadata.

Understanding semantic views

Note

Throughout this topic, database-related artifacts (such as database tables) are referred to as physical objects, and artifacts related to the semantic view are referred to as logical objects.

Within a semantic view, you define logical tables that typically correspond to business entities, such as customers, orders, or suppliers. You can define relationships between logical tables through joins on shared keys, enabling you to analyze data across entities (as you would when joining database tables).

Using logical tables, you can define:

  • Facts: Facts are row-level attributes in your data model that represent specific business events or transactions. While facts can be defined using aggregates from more detailed levels of data (such as SUM(t.x) where t represents data at a more detailed level), they are always presented as attributes at the individual row level of the logical table. Facts capture “how much” or “how many” at the most granular level, such as individual sales amounts, quantities purchased, or costs. It’s important to note that facts typically function as “helper” concepts within the semantic view to help construct dimensions and metrics.

  • Metrics: Metrics are quantifiable measures of business performance calculated by aggregating facts or other columns from the same table (using functions like SUM, AVG, and COUNT) across multiple rows. They transform raw data into meaningful business indicators, often combining multiple calculations in complex formulas. Examples include Total Revenue or Profit Margin Percentage. Metrics represent the KPIs in reports and dashboards that drive business decision-making.

  • Dimensions: Dimensions represent categorical attributes. They provide the contextual framework that gives meaning to metrics by grouping data into meaningful categories. They answer “who,” “what,” “where,” and “when” questions, such as purchase date, customer details, product category, or location. Typically text-based or hierarchical, dimensions enable users to filter, group, and analyze data from multiple perspectives.

In a semantic view, these three elements have distinct roles, but metrics and dimensions are the primary elements that you interact with when analyzing data through the semantic view. Facts provide the underlying row-level numerical data, metrics transform data into actionable insights through aggregation and calculation, and dimensions determine viewing perspectives.

Refer to the the Key Concepts section in the semantic model specification for more information.

Interfaces for working with semantic views

You can use the following interfaces to create and manage semantic views:

  • SQL commands: You can use SQL commands to create and manage semantic views directly. For information, see Using SQL commands to create and manage semantic views.

  • Cortex Analyst Semantic View Generator: You can use a wizard in Snowsight that guides you through the process of creating a semantic view. Cortex Analyst is able to interact with the semantic view using YAML. This wizard also contains a YAML editor. For information, see Using the Cortex Analyst Semantic View Generator. For details on using YAML to manage semantics, see the Cortex Analyst semantic model specification.

    Currently, if you plan to use a semantic view in Cortex Analyst, you should use the Cortex Analyst Semantic View Generator to create the view.

In addition, you can use the database object explorer to view details about semantic views.

Limitations

  • Currently, you cannot use a SELECT statement to query a semantic view.

    Semantic views are used by Cortex Analyst, which reads the information captured in the semantic view definition and generates the SQL against the physical tables directly.

  • Semantic views are not supported for replication.

Getting started

To get started with semantic views:

  1. Design your business data model.

    • What business entities exist in your data (for example, customers, products, orders, and so on)?

    • How do these entities relate to each other?

    • What metrics are important to your business?

    • What dimensions do you use to analyze these metrics?

  2. Map your business concepts to your physical data.

    • Which tables contain the data you need? We recommend starting with a simple star schema.

    • How will you join these tables?

    • What calculations are needed to derive your metrics?

  3. Create a semantic view.

    You can use one of these interfaces to create a semantic view.

  4. Use Cortex Analyst for natural language queries of your semantic view.

Additional information about semantic views

For additional information about semantic views, see the following topics:

Language: English