use std::collections::HashSet;
pub async fn discover_plugin_columns(
client: &clickhouse::Client,
database: &str,
table: &str,
) -> Result<Vec<String>, clickhouse::error::Error> {
#[derive(clickhouse::Row, serde::Deserialize)]
struct ColumnRow {
name: String,
}
let query = format!(
"SELECT name FROM system.columns WHERE database = '{}' AND table = '{}' ORDER BY position",
database, table
);
let rows: Vec<ColumnRow> = client.query(&query).fetch_all().await?;
let core_set: HashSet<&str> = super::row::CORE_COLUMNS.iter().copied().collect();
let exclude: HashSet<&str> = ["is_liquidation_cascade", "computed_at"]
.iter()
.copied()
.collect();
Ok(rows
.into_iter()
.map(|r| r.name)
.filter(|name| !core_set.contains(name.as_str()) && !exclude.contains(name.as_str()))
.collect())
}