uqa_execution/catalog/read/production/
hierarchy.rs1use super::{CatalogReadView, RelationNameResolution, SQLError};
10use crate::catalog::hierarchy::hierarchy_scan_entries_with_control;
11use uqa_core::memory::{Produced, ProductionControl};
12
13impl CatalogReadView {
14 pub fn hierarchy_scan_tables_with_control(
15 &self,
16 resolution: &RelationNameResolution,
17 name: &str,
18 include_descendants: bool,
19 control: &ProductionControl<'_>,
20 ) -> Result<Produced<Vec<String>>, SQLError> {
21 let candidates = self
22 .relation_names()
23 .relation_lookup_candidates_with_control(resolution, name, control)?;
24 let root = candidates
25 .iter()
26 .find(|relation| self.snapshot.tables.contains_key(*relation))
27 .ok_or_else(|| match control.copy_text(name) {
28 Ok(name) => SQLError::UnknownTable(name.into_parts().0),
29 Err(error) => error.into(),
30 })?;
31 hierarchy_scan_entries_with_control(
32 root,
33 include_descendants,
34 || self.snapshot.tables.iter(),
35 |table, parent| {
36 table
37 .hierarchy
38 .parents
39 .iter()
40 .any(|candidate| candidate == parent)
41 },
42 control,
43 )
44 }
45}