use crate::lint::finding::Finding;
use crate::lint::source_tree::SourceTree;
pub fn check(tree: &SourceTree) -> Vec<Finding> {
let mut out = Vec::new();
for table in &tree.catalog.tables {
let Some(po) = &table.partition_of else {
continue;
};
let found = tree
.catalog
.tables
.iter()
.any(|other| other.qname == po.parent);
if !found {
out.push(Finding::error(
"partition-references-unmanaged-parent",
format!(
"partition `{}` references parent `{}`, which is not declared in this \
project's managed schema",
table.qname, po.parent,
),
));
}
}
out
}