File size: 1,443 Bytes
12eff8e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---
language: en
license: apache-2.0
library_name: morphsql
pipeline_tag: text-classification
tags:
  - code
  - sql
  - agent
  - text-generation
  - text-classification
  - rag
  - sklearn
  - migration
  - snowflake
  - dbt
datasets:
  - dgvj-work/vertica-snowflake-pairs
metrics:
  - accuracy
---

# MorphSQL risk classifier

Small **TF-IDF + LogisticRegression** model that scores SQL migration risk (`low` / `medium` / `high`).

Used by **MorphSQL** ([Space](https://huggingface.co/spaces/dgvj-work/morphsql)).  
Python package import: `morphsql` (PyPI: `morphsql`).

## Files
| File | Purpose |
|------|---------|
| `risk_classifier.joblib` | sklearn pipeline |
| `rewrite_vocabulary.json` | common SQL rewrite map |
| `config.json` | dialects + metadata |

## Usage

```python
from huggingface_hub import hf_hub_download
import joblib

path = hf_hub_download(repo_id="dgvj-work/morphsql", filename="risk_classifier.joblib")
clf = joblib.load(path)
print(clf.predict(["EXECUTE IMMEDIATE 'SELECT 1'"]))
```

```python
from morphsql.ai import pipeline
print(pipeline("sql-risk-classification")("CREATE PROCEDURE p AS BEGIN NULL; END;"))
print(pipeline("sql-migration")("SELECT ZEROIFNULL(a) FROM t"))
```

## Links
- Space: https://huggingface.co/spaces/dgvj-work/morphsql
- Dataset: https://huggingface.co/datasets/dgvj-work/vertica-snowflake-pairs
- GitHub: https://github.com/dgvj-work/morphsql

Author: Digvijay Waghela · Apache-2.0