Skip to main content

vein_database/vector/
table_names.rs

1use anyhow::Result;
2use std::fs;
3use crate::paths::Paths;
4
5pub fn list_model_tables() -> Result<Vec<String>> {
6    let db_path = Paths::get_insights_db();
7
8    if !db_path.exists() {
9        return Ok(Vec::new());
10    }
11
12    let mut tables = Vec::new();
13
14    for entry in fs::read_dir(db_path)? {
15        let entry = entry?;
16        let path = entry.path();
17
18        if path.is_dir()
19            && let Some(name) = path.file_name()
20            && let Some(name_str) = name.to_str() {
21                // Remove .lance suffix if present to get clean table name
22                let clean_name = if name_str.ends_with(".lance") {
23                    name_str.trim_end_matches(".lance")
24                } else {
25                    name_str
26                };
27                tables.push(clean_name.to_string());
28        }
29    }
30
31    tables.sort();
32    Ok(tables)
33}