Working With the Snowflake Model Registry in SQL¶
Since models are first-class, schema-level objects, Snowflake SQL provides commands for working with them and their components. These are:
Model Commands
Model Version Commands
Calling Model Methods in SQL¶
You can call or invoke methods of a model in SQL using the model_name!method_name(...)
syntax. The methods
available on a model are determined by the underlying Python model class. For example, many types of models use a method
named predict
for inference.
To invoke a method of the default version of a model, use the syntax shown here, passing arguments to the method, if any, between the parentheses, and passing the name of the table containing the inference data in the FROM clause.
SELECT <model_name>!<method_name>(...) FROM <table_name>;
To invoke a method of a specific version of a model, first create an alias to the specific version of the model using WITH, then invoke the desired method through the alias.
WITH <model_version_alias> AS MODEL <model_name> VERSION <version>
SELECT <model_version_alias>!<method_name>(...) FROM <table_name>;