Using Snowsight to create and manage semantic views¶
In Snowsight, you can create and manage semantic views:
Creating a semantic view¶
In Snowsight, you can create a semantic view by using a wizard or by uploading a semantic model specification.
Using the wizard to create a semantic view¶
Note
To create a semantic view, you must use a role with the privileges described in Privileges required to create a semantic view.
Access the wizard for creating semantic views in one of the following ways:
In the Getting started step in the wizard:
From Location to store, select the database and schema where the model should be stored.
In Name, enter a name for your semantic view.
You must specify a name that starts with a letter or underscore and that only contains letters, numbers, underscores, or dollar signs.
(Optional) In Description, describe the data that your semantic view makes available.
Select Next.
In the Select tables step in the wizard:
In the All tab, select the tables or views that contain the data that you want to use in your semantic view. Note the following:
You must select at least one table or view.
For better performance, don’t select more than ten tables.
If you want see the list of tables and views that you selected, select the Selected tab.
Select Next.
In the Select columns step in the wizard:
Select the columns to include in the view.
To select all columns in a table or view, select the table or view.
For better performance, don’t select more than 50 columns.
Select Create and Save.
Under Logical tables:
Review the facts, dimensions, and metrics defined for each table or view.
Provide business-friendly names and descriptions.
Add any additional facts, dimensions, and metrics needed.
Under Relationships:
Confirm any relationships defined by the generator.
Modify relationship properties as needed.
Add any additional relationships needed.
If you made any changes to the semantic view, select Save.
Uploadating a YAML specification to create a semantic view¶
If you are planning to create the semantic view from Cortex Analyst, create a stage for the YAML file.
Upload the YAML file in one of the following ways:
-
In Snowsight, select Data » Databases.
Select the database and schema where you want to create the semantic view.
Select Create » Semantic View » Upload YAML file.
Select the YAML file to upload.
Under Select database, schema and stage, select the database, schema, and stage where you want to upload the YAML file.
If you want the YAML file uploaded to a specific path in the stage, specify that path.
Select Upload.
Cortex Analyst:
In Snowsight, select AI & ML » Cortex Analyst.
Select Create new » Upload YAML file.
Select the YAML file to upload.
Select Convert and save.
-
Editing a semantic view¶
To edit a semantic view:
Access the semantic view in one of the following ways:
-
In Snowsight, select Data » Databases.
Select the database and schema containing the semantic view.
Select Semantic views.
Select the semantic view.
Select the Semantic information tab.
Cortex Analyst:
In Snowsight, select AI & ML » Cortex Analyst.
Select the Semantic views tab.
Under Select database to see semantic views, select the database and schema containing the semantic view that you want to edit.
Select the semantic view that you want to edit.
-
Make changes to the semantic view. You can make the following types of changes:
To modify the name or description of the semantic view:
Select Edit next to the name of the semantic view.
Make changes to the name or description.
Select Apply.
To add a new logical table to the semantic view:
Select + Logical Table in the database object explorer or + in Cortex Analyst.
In the Select a table step in the wizard:
Select the table or view that contains the data that you want to use in your semantic view.
Select Next.
In the Select columns step in the wizard:
Select the columns to include in the view.
To select all columns in a table or view, select the table or view.
Select Generate logical table.
To make changes to the name, description, synonyms, or primary key of a logical table in the semantic view:
Select
» Edit Logical Table next to the logical table name in the database object explorer or Edit next to the logical table name in Cortex Analyst.
Make your changes to the name, description, synonyms, and primary key.
If you have not specified the description or synonyms, you can select Generate fields to fill in these fields automatically.
Select Save.
To add a fact, dimension, or metric:
To modify or remove a fact, dimension, or metric:
To add a relationship:
Open the form for adding the new item:
In the database object explorer, select + Relationship.
In Cortex Analyst, select + next to Relationships.
Enter a name for the relationship, select the tables in the relationship, and select the columns to use to join the tables.
Select Add.
If you plan to use Cortex Analyst with this view, consider the following:
Add sample queries to the Verified Queries section. Note that this section is available only in Cortex Analyst.
These are example queries that help Cortex Analyst understand how to use the semantic view.
Add queries that represent common use cases for your data.
Add synonyms for your tables, facts, dimensions, or metrics.
These are alternative terms that users might use in queries.
Synonyms help Cortex Analyst correctly interpret user questions.
Add custom instructions.
These provide additional context about how the data should be interpreted.
Include business rules or constraints that should be considered.
Select Save.
Granting the privilege to use a semantic view to another role¶
To grant another role the privileges to view and query a semantic view:
Access the semantic view in one of the following ways:
Select the role that should be granted the privileges to view and query the semantic view.
Select Done.
This grants the SELECT and REFERENCES privileges on the semantic view to the selected role.
Querying a semantic view¶
If you are viewing a semantic view in the database object explorer, you can open a worksheet to construct a query for that view
by selecting » Query with SQL.
For information on how to construct the query, see Querying semantic views.
Best practices for creating a semantic view¶
Provide clear descriptions:
Use business terminology in all names and descriptions.
Make descriptions detailed enough for non-technical users to understand.
Include representative user questions:
Include questions that can help the model generator better understand your intent.
Include variations of how questions might be asked.
Review generated suggestions carefully:
Make sure the questions are relevant for the use case.
Make sure the suggested relationships match your business understanding.
Test with real questions:
After creating your semantic view, test it with actual business questions.
Refine your semantic view, based on how well the model supports these questions.
Iterate on developing the semantic view:
Start with a simple star schema.
Start with core tables and metrics, then expand. We suggest three tables to keep things simple.
Get feedback from business users, and refine your semantic view.
Troubleshooting¶
If your semantic view is not listed in the list of views, refresh the list of models (not the page itself).
If errors occur with the relationships in the semantic view, ensure that these relationships match the actual data structure.
If queries are slow, reduce the number of tables or columns.
If Cortex Analyst produces unexpected results when using your semantic view, review the facts, dimensions, and metrics in the semantic view.