Schemas:

ACCOUNT_USAGE

SEMANTIC_METRICS view

This ACCOUNT_USAGE view displays a row for each metric defined in a semantic view.

See also:

SEMANTIC_METRICS view (Information Schema)

Columns

Column nameData typeDescription
semantic_metric_idNUMBERID of the metric in the semantic view.
semantic_metric_nameVARCHARName of the metric in the semantic view.
semantic_table_idNUMBERID of the logical table the metric belongs to.
semantic_table_nameVARCHARName of the logical table the metric belongs to.
semantic_view_idNUMBERInternal, Snowflake-generated identifier for the semantic view in which the metric is defined.
semantic_view_nameVARCHARName of the semantic view in which the metric is defined.
semantic_view_schema_idNUMBERInternal, Snowflake-generated identifier for the schema that the semantic view belongs to.
semantic_view_schema_nameVARCHARSchema that the semantic view belongs to.
semantic_view_database_idNUMBERInternal, Snowflake-generated identifier for the database that the semantic view belongs to.
semantic_view_database_nameVARCHARDatabase that the semantic view belongs to.
data_typeVARCHARData type of the metric expression.
expressionVARCHARThe SQL expression used to calculate the metric.
synonymsARRAY(VARCHAR)List of the synonyms for the metric.
commentVARCHARDescription of the metric.
createdTIMESTAMP_LTZCreation time of the metric.
last_alteredTIMESTAMP_LTZ

Date and time the object was last altered by a DML, DDL, or background metadata operation. See Usage Notes_.

deletedTIMESTAMP_LTZDate and time when the metric was dropped.

Usage notes

  • Latency for the view can be up to 120 minutes (2 hours).
  • The LAST_ALTERED column is updated when the following operations are performed on an object:

    • DDL operations.
    • DML operations (for tables only). This column is updated even when no rows are affected by the DML statement.
    • Background maintenance operations on metadata performed by Snowflake.

Examples

Retrieve the list of all metrics for the semantic view O_TPCH_SEMANTIC_VIEW in the database MY_DB:

SELECT * FROM SNOWFLAKE.ACCOUNT_USAGE.SEMANTIC_METRICS
  WHERE semantic_view_name = 'O_TPCH_SEMANTIC_VIEW'
    AND semantic_view_database_name = 'MY_DB';
i+--------------------+------------------------+-------------------+---------------------+------------------+----------------------+-------------------------+---------------------------+---------------------------+-----------------------------+--------------+--------------------------------------+----------+-------------------------------+-------------------------------+---------+---------+
| SEMANTIC_METRIC_ID | SEMANTIC_METRIC_NAME   | SEMANTIC_TABLE_ID | SEMANTIC_TABLE_NAME | SEMANTIC_VIEW_ID | SEMANTIC_VIEW_NAME   | SEMANTIC_VIEW_SCHEMA_ID | SEMANTIC_VIEW_SCHEMA_NAME | SEMANTIC_VIEW_DATABASE_ID | SEMANTIC_VIEW_DATABASE_NAME | DATA_TYPE    | EXPRESSION                           | SYNONYMS | CREATED                       | LAST_ALTERED                  | DELETED | COMMENT |
|--------------------+------------------------+-------------------+---------------------+------------------+----------------------+-------------------------+---------------------------+---------------------------+-----------------------------+--------------+--------------------------------------+----------+-------------------------------+-------------------------------+---------+---------|
|                396 | M_CUSTOMER_ORDER_COUNT |                99 | CUSTOMER            |               49 | O_TPCH_SEMANTIC_VIEW |                      92 | MY_SCHEMA                 |                         7 | MY_DB                       | NUMBER(30,0) | SUM(customer.a_customer_order_count) | NULL     | 2025-02-28 16:16:04.389 -0800 | 2025-02-28 16:16:04.389 -0800 | NULL    | NULL    |
|                395 | M_CUSTOMER_COUNT       |                99 | CUSTOMER            |               49 | O_TPCH_SEMANTIC_VIEW |                      92 | MY_SCHEMA                 |                         7 | MY_DB                       | NUMBER(18,0) | COUNT(c_custkey)                     | NULL     | 2025-02-28 16:16:04.389 -0800 | 2025-02-28 16:16:04.389 -0800 | NULL    | NULL    |
|                398 | M_SUPPLIER_COUNT       |               102 | SUPPLIER            |               49 | O_TPCH_SEMANTIC_VIEW |                      92 | MY_SCHEMA                 |                         7 | MY_DB                       | NUMBER(18,0) | COUNT(s_suppkey)                     | NULL     | 2025-02-28 16:16:04.389 -0800 | 2025-02-28 16:16:04.389 -0800 | NULL    | NULL    |
|                397 | M_ORDER_COUNT          |               100 | ORDERS              |               49 | O_TPCH_SEMANTIC_VIEW |                      92 | MY_SCHEMA                 |                         7 | MY_DB                       | NUMBER(18,0) | COUNT(o_orderkey)                    | NULL     | 2025-02-28 16:16:04.389 -0800 | 2025-02-28 16:16:04.389 -0800 | NULL    | NULL    |
+--------------------+------------------------+-------------------+---------------------+------------------+----------------------+-------------------------+---------------------------+---------------------------+-----------------------------+--------------+--------------------------------------+----------+-------------------------------+-------------------------------+---------+---------+