SHOW SEMANTIC METRICS¶
Lists the metrics in the semantic views for which you have access privileges.
You can use this command to list objects in the current database and schema for the session, a specified database or schema, or your entire account.
The output includes the metadata and properties for each object. The objects are sorted lexicographically by database, schema, and object name (see Output in this topic for descriptions of the output columns). The order is important to note if you want to filter the results.
- See also:
CREATE SEMANTIC VIEW , DESCRIBE SEMANTIC VIEW , DROP SEMANTIC VIEW , SHOW SEMANTIC VIEWS , SHOW SEMANTIC DIMENSIONS , SHOW SEMANTIC DIMENSIONS FOR METRIC
Syntax¶
SHOW SEMANTIC METRICS [ LIKE '<pattern>' ]
[ IN
{
<semantic_view_name> |
ACCOUNT |
DATABASE |
DATABASE <database_name> |
SCHEMA |
SCHEMA <schema_name>
}
]
[ STARTS WITH '<name_string>' ]
[ LIMIT <rows> ]
Parameters¶
LIKE 'pattern'
Optionally filters the command output by object name. The filter uses case-insensitive pattern matching, with support for SQL wildcard characters (
%
and_
).For example, the following patterns return the same results:
... LIKE '%testing%' ...
... LIKE '%TESTING%' ...
. Default: No value (no filtering is applied to the output).
[ IN ... ]
Optionally specifies the scope of the command. Specify one of the following:
semantic_view_name
Returns records for the specified semantic view.
ACCOUNT
Returns records for the entire account.
DATABASE
, .DATABASE db_name
Returns records for the current database in use or for a specified database (
db_name
).If you specify
DATABASE
withoutdb_name
and no database is in use, the keyword has no effect on the output.SCHEMA
, .SCHEMA database_name.schema_name
Returns records for the current schema in use or a specified schema (
database_name.schema_name
).If no database is in use, specifying
SCHEMA
has no effect on the output.
Default: Depends on whether the session currently has a database in use:
Database:
DATABASE
is the default (that is, the command returns the objects you have privileges to view in the database).No database:
ACCOUNT
is the default (that is, the command returns the objects you have privileges to view in your account).
STARTS WITH 'name_string'
Optionally filters the command output based on the characters that appear at the beginning of the object name. The string must be enclosed in single quotes and is case sensitive.
For example, the following strings return different results:
... STARTS WITH 'B' ...
... STARTS WITH 'b' ...
. Default: No value (no filtering is applied to the output)
LIMIT rows
Optionally limits the maximum number of rows returned. The actual number of rows returned might be less than the specified limit. For example, the number of existing objects is less than the specified limit.
Default: No value (no limit is applied to the output).
Output¶
The output of the command includes the following columns, which describe the properties and metadata of the object:
Column |
Description |
---|---|
|
Name of the database that contains the semantic view. |
|
Name of the schema that contains the semantic view. |
|
Name of the semantic view that contains the metric. |
|
Name of the base table for the metric. |
|
Name of the metric. |
|
Data type of the metric. |
|
Alternative names or synonyms for the metric. |
|
Comment about the metric. |
Access control requirements¶
A role used to execute this SQL command must have at least one of the following privileges at a minimum:
Privilege |
Object |
Notes |
---|---|---|
Any |
Semantic view |
The USAGE privilege on the parent database and schema are required to perform operations on any object in a schema.
For instructions on creating a custom role with a specified set of privileges, see Creating custom roles.
For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.
Usage notes¶
The command doesn’t require a running warehouse to execute.
The command only returns objects for which the current user’s current role has been granted at least one access privilege.
The MANAGE GRANTS access privilege implicitly allows its holder to see every object in the account. By default, only the account administrator (users with the ACCOUNTADMIN role) and security administrator (users with the SECURITYADMIN role) have the MANAGE GRANTS privilege.
To post-process the output of this command, you can use the pipe operator or the RESULT_SCAN function. Both constructs treat the output as a result set that you can query.
The command returns a maximum of ten thousand records for the specified object type, as dictated by the access privileges for the role used to execute the command. Any records above the ten thousand records limit aren’t returned, even with a filter applied.
To view results for which more than ten thousand records exist, query the corresponding view (if one exists) in the Snowflake Information Schema.
The value for
LIMIT rows
can’t exceed10000
. IfLIMIT rows
is omitted, the command results in an error if the result set is larger than ten thousand rows.To view results for which more than ten thousand records exist, either include
LIMIT rows
or query the corresponding view in the Snowflake Information Schema.
Executing the command for schema-level objects only returns an object if the current role also has at least one privilege on the parent database and schema.
Examples¶
The following example lists the metrics for semantic views that you have any privilege on. The list includes metrics in semantic views in the current schema of the current database.
SHOW SEMANTIC METRICS;
+---------------+-------------+--------------------+------------+------------------------------+--------------+----------+----------------------------------------+
| database_name | schema_name | semantic_view_name | table_name | name | data_type | synonyms | comment |
|---------------+-------------+--------------------+------------+------------------------------+--------------+----------+----------------------------------------|
| MY_DB | MY_SCHEMA | TPCH_ANALYSIS | CUSTOMER | CUSTOMER_COUNT | NUMBER(18,0) | NULL | NULL |
| MY_DB | MY_SCHEMA | TPCH_ANALYSIS | CUSTOMER | CUSTOMER_ORDER_COUNT | NUMBER(30,0) | NULL | NULL |
| MY_DB | MY_SCHEMA | TPCH_ANALYSIS | ORDERS | AVERAGE_LINE_ITEMS_PER_ORDER | NUMBER(36,6) | NULL | NULL |
| MY_DB | MY_SCHEMA | TPCH_ANALYSIS | ORDERS | ORDER_AVERAGE_VALUE | NUMBER(30,8) | NULL | NULL |
| MY_DB | MY_SCHEMA | TPCH_ANALYSIS | ORDERS | ORDER_COUNT | NUMBER(18,0) | NULL | NULL |
| MY_DB | MY_SCHEMA | TPCH_ANALYSIS | SUPPLIER | SUPPLIER_COUNT | NUMBER(18,0) | NULL | NULL |
| MY_DB | MY_SCHEMA | TPCH_REV_ANALYSIS | CUSTOMERS | CUSTOMER_COUNT | NUMBER(18,0) | NULL | Count of number of customers |
| MY_DB | MY_SCHEMA | TPCH_REV_ANALYSIS | ORDERS | AVERAGE_LINE_ITEMS_PER_ORDER | NUMBER(36,6) | NULL | Average number of line items per order |
| MY_DB | MY_SCHEMA | TPCH_REV_ANALYSIS | ORDERS | ORDER_AVERAGE_VALUE | NUMBER(30,8) | NULL | Average order value across all orders |
+---------------+-------------+--------------------+------------+------------------------------+--------------+----------+----------------------------------------+
The following example lists the metrics for the semantic view named tpch_rev_analysis
in the current schema of the current database:
SHOW SEMANTIC METRICS IN tpch_rev_analysis;
+---------------+-------------+--------------------+------------+------------------------------+--------------+----------+----------------------------------------+
| database_name | schema_name | semantic_view_name | table_name | name | data_type | synonyms | comment |
|---------------+-------------+--------------------+------------+------------------------------+--------------+----------+----------------------------------------|
| MY_DB | MY_SCHEMA | TPCH_REV_ANALYSIS | CUSTOMERS | CUSTOMER_COUNT | NUMBER(18,0) | NULL | Count of number of customers |
| MY_DB | MY_SCHEMA | TPCH_REV_ANALYSIS | ORDERS | AVERAGE_LINE_ITEMS_PER_ORDER | NUMBER(36,6) | NULL | Average number of line items per order |
| MY_DB | MY_SCHEMA | TPCH_REV_ANALYSIS | ORDERS | ORDER_AVERAGE_VALUE | NUMBER(30,8) | NULL | Average order value across all orders |
+---------------+-------------+--------------------+------------+------------------------------+--------------+----------+----------------------------------------+