Search code examples
machine-learningmodelsvertica

Delete/Drop Machine Learning Models in Vertica if exists


Is it possible to check if a model exists before deleting it using DELETE_MODEL I am trying to avoid getting an error message while trying to delete a model that is not yet created. Basiscally I am looking for counterpart of: DROP TABLE IF EXISTS but for models.


Solution

  • This is how you check for its existence from vsql:

    sbx_marco=> \x
    Expanded display is on.
    sbx_marco=> select * from models where model_name ilike 'logisticRegModel';
    -[ RECORD 1 ]--+------------------------------------------
    schema_name    | public
    model_owner    | dbadmin
    category       | Vertica_Models
    model_name     | logisticregmodel
    model_type     | logistic regression
    format_version | Vertica Analytic Database v8.0.0-20160801
    mode_size      | 996
    deploy_time    | 2016-08-24 13:59:14.01-04 
    

    So it will be about creating a script that, for example, counts the models with a given name -and a given owner, and if the count is 0, does not do anything, otherwise deletes the model ...

    A WHERE condition?