SHOW SEMANTIC FACTS¶
Lists the facts 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 of rows in the results is important to note if you want to filter the results.
- See also:
CREATE SEMANTIC VIEW , ALTER SEMANTIC VIEW , DESCRIBE SEMANTIC VIEW , DROP SEMANTIC VIEW , SHOW SEMANTIC VIEWS , SHOW SEMANTIC DIMENSIONS , SHOW SEMANTIC DIMENSIONS FOR METRIC , SHOW SEMANTIC METRICS
Syntax¶
SHOW SEMANTIC FACTS [ LIKE '<pattern>' ]
[ IN
{
<semantic_view_name> |
ACCOUNT |
DATABASE |
DATABASE <db_name> |
SCHEMA |
SCHEMA <db_name>.<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 db_name.schema_name
Returns records for the current schema in use or a specified schema (
db_name.schema_name
). You must specify the fully qualified name of the schema.If no database is in use, specifying
SCHEMA
has no effect on the output.
If you omit
IN ...
, the scope of the command depends on whether the session currently has a database in use:If a database is currently in use, the command returns the objects you have privileges to view in the database. This has the same effect as specifiying
IN DATABASE
.If no database is currently in use, the command returns the objects you have privileges to view in your account. This has the same effect as specifiying
IN 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 fact. |
|
Name of the logical table for the fact. |
|
Name of the fact. |
|
Data type of the fact. |
|
Alternative names or synonyms for the fact. |
|
Comment about the fact. |
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 |
|
REFERENCES or OWNERSHIP |
Semantic view |
One of these privileges is required if you want the output to include private facts. |
The USAGE privilege on the parent database and schema are required to perform operations on any object in a schema.
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 output column names for this command are generated in lowercase. If you consume a result set from this command with the pipe operator or the RESULT_SCAN function, use double-quoted identifiers for the column names in the query to ensure that they match the column names in the output that was scanned. For example, if the name of an output column is
type
, then specify"type"
for the identifier.
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 facts for semantic views that you have any privilege on. The list includes facts in semantic views in the current schema of the current database.
SHOW SEMANTIC FACTS;
+---------------+-------------+--------------------+------------+------------------------+--------------------+----------+-------------------------------+
| database_name | schema_name | semantic_view_name | table_name | name | data_type | synonyms | comment |
|---------------+-------------+--------------------+------------+------------------------+--------------------+----------+-------------------------------|
| MY_DB | MY_SCHEMA | TPCH_ANALYSIS | CUSTOMER | C_CUSTOMER_ORDER_COUNT | NUMBER(18,0) | NULL | NULL |
| MY_DB | MY_SCHEMA | TPCH_ANALYSIS | LINEITEM | LINE_ITEM_ID | VARCHAR(134217728) | NULL | NULL |
| MY_DB | MY_SCHEMA | TPCH_ANALYSIS | NATION | N_NAME | VARCHAR(25) | NULL | NULL |
| MY_DB | MY_SCHEMA | TPCH_ANALYSIS | ORDERS | COUNT_LINE_ITEMS | NUMBER(18,0) | NULL | NULL |
| MY_DB | MY_SCHEMA | TPCH_ANALYSIS | ORDERS | O_ORDERKEY | NUMBER(38,0) | NULL | NULL |
| MY_DB | MY_SCHEMA | TPCH_ANALYSIS | REGION | R_NAME | VARCHAR(25) | NULL | NULL |
| MY_DB | MY_SCHEMA | TPCH_REV_ANALYSIS | LINE_ITEMS | DISCOUNTED_PRICE | NUMBER(25,4) | NULL | Extended price after discount |
| MY_DB | MY_SCHEMA | TPCH_REV_ANALYSIS | LINE_ITEMS | LINE_ITEM_ID | VARCHAR(134217728) | NULL | NULL |
| MY_DB | MY_SCHEMA | TPCH_REV_ANALYSIS | ORDERS | COUNT_LINE_ITEMS | NUMBER(18,0) | NULL | NULL |
+---------------+-------------+--------------------+------------+------------------------+--------------------+----------+-------------------------------+
The following example lists the facts for the semantic view named tpch_rev_analysis
in the current schema of the current
database:
SHOW SEMANTIC FACTS 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 | LINE_ITEMS | DISCOUNTED_PRICE | NUMBER(25,4) | NULL | Extended price after discount |
| MY_DB | MY_SCHEMA | TPCH_REV_ANALYSIS | LINE_ITEMS | LINE_ITEM_ID | VARCHAR(134217728) | NULL | NULL |
| MY_DB | MY_SCHEMA | TPCH_REV_ANALYSIS | ORDERS | COUNT_LINE_ITEMS | NUMBER(18,0) | NULL | NULL |
+---------------+-------------------+--------------------+------------+------------------+--------------------+----------+-------------------------------+