Documentation Home
MySQL HeatWave User Guide
Related Documentation Download this Manual
PDF (US Ltr) - 1.0Mb
PDF (A4) - 1.0Mb


MySQL HeatWave User Guide  /  ...  /  Sharing Models

3.7.9 Sharing Models

Sharing a model requires granting model catalog privileges to another user. You can only share a model with another MySQL user on the same MySQL DB System.

To grant model catalog privileges, issue a statement similar to the following:

GRANT SELECT, ALTER, INSERT, CREATE, UPDATE, DROP, GRANT OPTION 
ON ML_SCHEMA_user1.MODEL_CATALOG 
TO 'user2'@'%';

where:

  • ML_SCHEMA_user1.MODEL_CATALOG is the fully qualified name of the MODEL_CATALOG table. The schema is named for the user that created the model.

  • 'user2'@'%' is the user you want to grant access to.

Note

The user that is granted model catalog privileges must also have the privileges required to use HeatWave ML and the CREATE privilege on the schema where ML_PREDICT_TABLE or ML_EXPLAIN_TABLE results are written. See Section 3.1, “Before You Begin”.

After a model catalog is shared with another user, that user can access models in the catalog when running ML_* routines. For example, 'user2'@'%' in the example above might assign a model handle from the user1 model catalog to a session variable, and call that session variable from a ML_PREDICT_TABLE routine. The model owner is responsible for loading a model shared with other users.

mysql> SET @my_model = (SELECT model_handle 
  FROM ML_SCHEMA_user1.MODEL_CATALOG 
  WHERE train_table_name LIKE '%census_train%');
  
mysql> SELECT @my_model;
+--------------------------------------------------+
| @my_model                                        |
+--------------------------------------------------+
| heatwaveml_bench.census_train_user1_1648167434   |
+--------------------------------------------------+
 
mysql> CALL sys.ML_PREDICT_TABLE('heatwaveml_bench.census_test_subset', @my_model, 
'heatwaveml_bench.census_predictions');