SYSTEM$CREATE_ SEMANTIC_ VIEW_ FROM_ YAML¶
Creates a semantic view from a semantic model specification in YAML format, or verifies that you can use a semantic model specification to create a semantic view.
The stored procedure uses the name from the YAML specification for the name of the semantic view.
If a semantic view with the same name already exists, the stored procedure attempts to replace that semantic view and copy the grants from that semantic view. This has the same effect as running CREATE OR REPLACE SEMANTIC VIEW … COPY GRANTS.
Syntax¶
Arguments¶
Required:
'fully_qualified_schema_name'Fully qualified name of the schema where you want to create the semantic view.
You must qualify the schema name with the database name (for example,
my_db.my_schema). Otherwise, an error occurs.'yaml_specification'Semantic model specification in YAML format.
If the specification contains quotes, backslashes, or newlines, you can use a dollar-quoted string constant for this argument.
Optional:
verify_onlyIf TRUE, verifies that you can use the semantic model specified by
'yaml_specification'to create a semantic view.You can specify this to verify that you can create a semantic view from the model before you attempt to create the semantic view.
Default: FALSE
Returns¶
Returns a VARCHAR value containing the status of the operation to create the semantic view or verify that the semantic view can be created.
If the stored procedure fails to create the semantic view or verify that the semantic view can be created, the stored procedure throws an exception.
Access control requirements¶
A role used to execute this operation must have the following privileges at a minimum:
| Privilege | Object | Notes |
|---|---|---|
| CREATE SEMANTIC VIEW | Schema | Required to create a new semantic view. |
| SELECT | Table, view | Required on any tables and/or views used in the semantic view definition. |
| OWNERSHIP | Existing semantic view with the same name. | If a semantic view with the same name already exists, the stored procedure attempts to replace that semantic view. To replace an existing semantic view, you must use a role that has been granted the OWNERSHIP privilege. OWNERSHIP is a special privilege on an object that is automatically granted to the role that created the object, but can also be transferred using the [GRANT OWNERSHIP](/sql-reference/sql/grant-ownership) command to a different role by the owning role (or any role with the MANAGE GRANTS privilege). |
Operating on an object in a schema requires at least one privilege on the parent database and at least one privilege on the parent 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¶
If the name of the database or schema is a double-quoted identifier (for example, if the name contains spaces), you must include double quotes around the name. For example:
Examples¶
The following example verifies that you can use a given semantic model specification in YAML to create a semantic view named
tpch_analysis in the database my_db and schema my_schema:
If the specification is valid, the stored procedure returns the following message:
If the YAML syntax is invalid, the stored procedure throw an exception. For example, if a colon is missing:
the stored procedure throws an exception, indicating that the YAML syntax is invalid:
If the specification refers to a physical table that does not exist, the stored procedure throws an exception:
Similarly, if the specification refers to a primary key column that does not exist, the stored procedure throws an exception:
The following example creates a semantic view named tpch_analysis in the database my_db and schema my_schema: