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


HeatWave User Guide  /  ...  /  ML_MODEL_EXPORT

3.16.3 ML_MODEL_EXPORT

MySQL 9.0.0 introduces the ML_MODEL_EXPORT routine. Use this routine to export a model from the model catalog to a user defined table.

MySQL 9.0.0 also introduces support for large models that changes how HeatWave AutoML stores models, see: Section 3.14.1, “The Model Catalog”. ML_MODEL_EXPORT upgrades older models.

The output table will have these columns:

ML_MODEL_EXPORT should work regardless of model_metadata.status:

  • If there is no corresponding row in the model_object_catalog for an existing model_handle in the MODEL_CATALOG:

    There should be only one row in the output table with chunk_id = 0, model_object = NULL and model_metadata = MODEL_CATALOG.model_metadata.

  • If there is at least one row in the model_object_catalog for an existing model_handle in the MODEL_CATALOG:

    • There should be N rows in the output table with chunk_id being 1 to N.

    • ML_MODEL_EXPORT copies the model_object from model_object_catalog to the output table.

    • model_metadata in the row with chunk_id = 1 should be the same as in the MODEL_CATALOG.

If a user subsequently uses ML_MODEL_IMPORT to import the model into a different MySQL DB System, the results will depend upon the MySQL version:

  • If the MySQL DB System has MySQL 9.0.0 or greater, the import should work.

  • If the MySQL DB System has a MySQL version before Mysql 9.0.0:

    • If the model format is HWMLv2.0 or ONNXv2.0, then the import will fail.

    • If the model format is HWMLv1.0, ONNXv1.0 or ONNX, make the following changes:

      • Drop model_metadata.chunks.

      • Change the model format to ONNX if the model format is ONNXv1.0.

      The import should then succeed.

ML_MODEL_EXPORT Syntax

As of MySQL 9.0.0, ML_MODEL_EXPORT can export a model from the model_object_catalog to a user defined table.

mysql> CALL sys.ML_MODEL_EXPORT (model_handle, output_table_name);

ML_MODEL_EXPORT parameters:

  • model_handle: The model handle for the model.

  • output_table_name: The name for the output table.

Syntax Examples

  • An example that exports a HeatWave AutoML model with metadata:

    mysql> CALL sys.ML_MODEL_EXPORT(@iris_model, 'ML_SCHEMA_user1.model_export');
    Query OK, 0 rows affected (0.06 sec)
    
    mysql> SHOW CREATE TABLE ML_SCHEMA_user1.model_export;
    +--------------+--------------------------------------------------------------------+
    | Table        | Create Table                                                       |
    +--------------+--------------------------------------------------------------------+
    | model_export | CREATE TABLE `model_export` (
      `chunk_id` int NOT NULL AUTO_INCREMENT,
      `model_object` longtext,
      `model_metadata` json DEFAULT NULL,
      PRIMARY KEY (`chunk_id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
    +--------------+--------------------------------------------------------------------+
    1 row in set (0.00 sec)