pub fn schema_adjacent_indexed_relations(
        &self,
        ids: &[GlobalId],
        conn_id: u32,
    ) -> Vec<GlobalId> {
        // Find all relations referenced by the expression. Find their parent schemas
        // and add all tables, views, and sources in those schemas to a set.
        let mut relations: HashSet<GlobalId> = HashSet::new();
        let mut schema_ids = VecDeque::new();
        for id in ids {
            // Always add in the user-specified ids.
            relations.insert(*id);
            let entry = self.get_by_id(&id);
            let name = entry.name();
            if let Some(schema) = self.get_schema(&name.database, &name.schema, conn_id) {
                schema_ids.extend(schema.items.values());
                while let Some(id) = schema_ids.pop_front() {
                    let entry = self.get_by_id(id);
                    let ty = entry.item_type();
                    match ty {
                        SqlCatalogItemType::Table => {
                            relations.insert(*id);
                        }
                        SqlCatalogItemType::View | SqlCatalogItemType::Source => {
                            let (indexes, unmaterialized) = self.nearest_indexes(&[*id]);
                            relations.extend(indexes);
                            // Add in the view/source if fully materialized.
                            if unmaterialized.is_empty() {
                                relations.insert(*id);
                                if let SqlCatalogItemType::View = ty {
                                    // Add transitive items from views.
                                    if let CatalogItem::View(view) = entry.item() {
                                        schema_ids.extend(&view.depends_on);
                                    }
                                }
                            }
                        }
                        _ => {}
                    }
                }
            }
        }
        relations.into_iter().collect()
    }
/// Returns all tables, views, and sources in the same schemas as a set of
/// input ids. The indexes of all relations are included.
Returns all tables, views, and sources in the same schemas as a set of
input ids. The indexes of all relations are included.
Returns all tables views and sources in the same schemas as a set of input ids . The indexes of all relations are included .
pub fn schema_adjacent_indexed_relations(
        &self,
        ids: &[GlobalId],
        conn_id: u32,
    ) -> Vec<GlobalId> {
        // Find all relations referenced by the expression. Find their parent schemas
        // and add all tables, views, and sources in those schemas to a set.
        let mut relations: HashSet<GlobalId> = HashSet::new();
        let mut schema_ids = VecDeque::new();
        for id in ids {
            // Always add in the user-specified ids.
            relations.insert(*id);
            let entry = self.get_by_id(&id);
            let name = entry.name();
            if let Some(schema) = self.get_schema(&name.database, &name.schema, conn_id) {
                schema_ids.extend(schema.items.values());
                while let Some(id) = schema_ids.pop_front() {
                    let entry = self.get_by_id(id);
                    let ty = entry.item_type();
                    match ty {
                        SqlCatalogItemType::Table => {
                            relations.insert(*id);
                        }
                        SqlCatalogItemType::View | SqlCatalogItemType::Source => {
                            let (indexes, unmaterialized) = self.nearest_indexes(&[*id]);
                            relations.extend(indexes);
                            // Add in the view/source if fully materialized.
                            if unmaterialized.is_empty() {
                                relations.insert(*id);
                                if let SqlCatalogItemType::View = ty {
                                    // Add transitive items from views.
                                    if let CatalogItem::View(view) = entry.item() {
                                        schema_ids.extend(&view.depends_on);
                                    }
                                }
                            }
                        }
                        _ => {}
                    }
                }
            }
        }
        relations.into_iter().collect()
    }
pub fn schema_adjacent_indexed_relations ( & self , ids : & [ GlobalId ] , conn_id : u32 , ) -> Vec < GlobalId > { // Find all relations referenced by the expression. Find their parent schemas // and add all tables, views, and sources in those schemas to a set. let mut relations : HashSet < GlobalId > = HashSet :: new ( ) ; let mut schema_ids = VecDeque :: new ( ) ; for id in ids { // Always add in the user-specified ids. relations . insert ( * id ) ; let entry = self . get_by_id ( & id ) ; let name = entry . name ( ) ; if let Some ( schema ) = self . get_schema ( & name . database , & name . schema , conn_id ) { schema_ids . extend ( schema . items . values ( ) ) ; while let Some ( id ) = schema_ids . pop_front ( ) { let entry = self . get_by_id ( id ) ; let ty = entry . item_type ( ) ; match ty { SqlCatalogItemType :: Table => { relations . insert ( * id ) ; } SqlCatalogItemType :: View | SqlCatalogItemType :: Source => { let ( indexes , unmaterialized ) = self . nearest_indexes ( & [ * id ] ) ; relations . extend ( indexes ) ; // Add in the view/source if fully materialized. if unmaterialized . is_empty ( ) { relations . insert ( * id ) ; if let SqlCatalogItemType :: View = ty { // Add transitive items from views. if let CatalogItem :: View ( view ) = entry . item ( ) { schema_ids . extend ( & view . depends_on ) ; } } } } _ => { } } } } } relations . into_iter ( ) . collect ( ) }
Returns all tables, views, and sources in the same schemas as a set of
input ids.
Returns all tables views and sources in the same schemas as a set of input ids .
&self
ids
&[GlobalId]
conn_id
u32
&self
ids
&[GlobalId]
conn_id
u32