> ## Documentation Index
> Fetch the complete documentation index at: https://docs.omni.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Snowflake semantic view example

> A Snowflake semantic view definition and the Omni topic generated from it, covering comments, synonyms, filters, and AI instructions.

This page shows a Snowflake semantic view definition and the topic Omni generates from it. The semantic view uses comments, synonyms, a filter-labeled fact, and AI instructions. For the full mapping behind each line, see the [metadata reference](/connect-data/snowflake-semantic-views/sync/metadata-reference).

```sql title="Snowflake semantic view" theme={null}
CREATE SEMANTIC VIEW ANALYTICS.SALES.ORDERS_USERS
  TABLES (
    ORDERS AS ANALYTICS.SALES.RAW_ORDERS PRIMARY KEY (ORDER_ID) COMMENT = 'One row per order',
    USERS  AS ANALYTICS.SALES.RAW_USERS  PRIMARY KEY (USER_ID)
  )
  RELATIONSHIPS (
    ORDERS_TO_USERS AS ORDERS (USER_ID) REFERENCES USERS (USER_ID)
  )
  FACTS (
    ORDERS.AMOUNT AS AMOUNT,
    ORDERS.LARGE_ORDER LABELS = (FILTER) AS AMOUNT > 500 COMMENT = 'Orders over $500'
  )
  DIMENSIONS (
    ORDERS.STATUS AS STATUS,
    USERS.REGION AS REGION WITH SYNONYMS ('territory')
  )
  METRICS (
    ORDERS.TOTAL_REVENUE AS SUM(AMOUNT) WITH SYNONYMS ('sales') COMMENT = 'Gross order value'
  )
  COMMENT = 'Orders joined to their users'
  AI_QUESTION_CATEGORIZATION = 'Questions about orders, revenue, or customers belong here.'
  AI_SQL_GENERATION = 'Revenue means TOTAL_REVENUE. Filter on STATUS = ''COMPLETE'' unless asked otherwise.'
```

Omni generates this topic. `SALES` is the connection's default schema, so the names are not schema-prefixed:

```yaml title="orders_users.topic" theme={null}
semantic_view: ANALYTICS.SALES.ORDERS_USERS
label: Orders Users
description: Orders joined to their users
ai_context: |
  Use these instructions for question categorization: Questions about orders, revenue, or customers belong here.

  Use these instructions for SQL generation: Revenue means TOTAL_REVENUE. Filter on STATUS = 'COMPLETE' unless asked otherwise.

relationships:
  - join_from_view: orders_users__orders
    join_to_view: orders_users__users
    on_sql: ${orders_users__orders.user_id} = ${orders_users__users.user_id}
    relationship_type: many_to_one

views:
  orders_users__orders:
    label: Orders
    description: One row per order
    table_name: RAW_ORDERS
    dimensions:
      order_id:
        sql: '"ORDER_ID"'
        primary_key: true
        hidden: true
      user_id:
        sql: '"USER_ID"'
        hidden: true
      status:
        sql: '"STATUS"'
      amount:
        sql: '"AMOUNT"'
      large_order:
        sql: ${orders_users__orders.amount} > 500
        description: Orders over $500
        hidden: true
    filters:
      large_order__filter:
        bind_to: large_order
        label: Large Order
        group_label: Filters
        description: Orders over $500
    measures:
      total_revenue:
        sql: SUM(${orders_users__orders.amount})
        description: Gross order value
        synonyms: [sales]

  orders_users__users:
    label: Users
    table_name: RAW_USERS
    dimensions:
      user_id:
        sql: '"USER_ID"'
        primary_key: true
        hidden: true
      region:
        sql: '"REGION"'
        synonyms: [territory]
```

`large_order` is hidden; users apply `large_order__filter` from the **Filters** group.

## Next steps

* Look up [what each part of a definition becomes in Omni](/connect-data/snowflake-semantic-views/sync/metadata-reference)
* Learn [what Omni creates for each semantic view](/connect-data/snowflake-semantic-views/sync/trigger-sync)
* Resolve [schema refresh warnings and query messages](/connect-data/snowflake-semantic-views/sync/trigger-sync#troubleshooting)
