use crate::project::models::OnSchemaChange;
pub fn missing_columns_warnings(
missing: &[String],
(place, loads): (&str, &str),
on_schema_change: OnSchemaChange,
) -> Result<Vec<String>, String> {
let lines = missing
.iter()
.map(|name| format!("declared column {name} is in none of {place}"));
match on_schema_change {
_ if missing.is_empty() => Ok(Vec::new()),
OnSchemaChange::Fail => Err(lines
.map(|line| {
format!(
"{line} and on_schema_change = \"fail\"; add it to the data, or remove it from columns"
)
})
.collect::<Vec<String>>()
.join("; ")),
OnSchemaChange::AppendNewColumns | OnSchemaChange::Ignore => {
Ok(lines.map(|line| format!("{line}, so {loads}")).collect())
}
}
}