catalog/system_schema/
utils.rs1use std::sync::Weak;
16
17use common_meta::key::TableMetadataManagerRef;
18use snafu::OptionExt;
19
20use crate::error::{GetInformationExtensionSnafu, Result, UpgradeWeakCatalogManagerRefSnafu};
21use crate::information_schema::InformationExtensionRef;
22use crate::kvbackend::KvBackendCatalogManager;
23use crate::CatalogManager;
24
25pub mod tables;
26
27pub fn information_extension(
29 catalog_manager: &Weak<dyn CatalogManager>,
30) -> Result<InformationExtensionRef> {
31 let catalog_manager = catalog_manager
32 .upgrade()
33 .context(UpgradeWeakCatalogManagerRefSnafu)?;
34
35 let information_extension = catalog_manager
36 .as_any()
37 .downcast_ref::<KvBackendCatalogManager>()
38 .map(|manager| manager.information_extension())
39 .context(GetInformationExtensionSnafu)?;
40
41 Ok(information_extension)
42}
43
44pub fn table_meta_manager(
46 catalog_manager: &Weak<dyn CatalogManager>,
47) -> Result<Option<TableMetadataManagerRef>> {
48 let catalog_manager = catalog_manager
49 .upgrade()
50 .context(UpgradeWeakCatalogManagerRefSnafu)?;
51
52 Ok(catalog_manager
53 .as_any()
54 .downcast_ref::<KvBackendCatalogManager>()
55 .map(|manager| manager.table_metadata_manager_ref().clone()))
56}