MCPcopy Create free account
hub / github.com/apache/paimon-rust / register_catalog

Method register_catalog

crates/integrations/datafusion/src/sql_context.rs:114–146  ·  view source on GitHub ↗

Registers a Paimon catalog under the given name. The first registered catalog automatically becomes the current catalog for both Paimon-handled SQL and DataFusion-delegated SQL (SELECT, etc.). A "default" database is created if it does not already exist (matching the behavior of Spark/Flink Paimon catalogs).

(
        &mut self,
        catalog_name: impl Into<String>,
        catalog: Arc<dyn Catalog>,
    )

Source from the content-addressed store, hash-verified

112 /// A "default" database is created if it does not already exist (matching
113 /// the behavior of Spark/Flink Paimon catalogs).
114 pub async fn register_catalog(
115 &mut self,
116 catalog_name: impl Into<String>,
117 catalog: Arc<dyn Catalog>,
118 ) -> DFResult<()> {
119 let catalog_name = catalog_name.into();
120 let is_first = self.catalogs.is_empty();
121 let default_db = "default";
122 match catalog.get_database(default_db).await {
123 Ok(_) => {}
124 Err(paimon::Error::DatabaseNotExist { .. }) => {
125 catalog
126 .create_database(default_db, true, Default::default())
127 .await
128 .map_err(|e| DataFusionError::External(Box::new(e)))?;
129 }
130 Err(e) => return Err(DataFusionError::External(Box::new(e))),
131 }
132 self.ctx.register_catalog(
133 &catalog_name,
134 Arc::new(crate::catalog::PaimonCatalogProvider::with_dynamic_options(
135 catalog.clone(),
136 self.dynamic_options.clone(),
137 )),
138 );
139 register_table_functions(&self.ctx, &catalog, default_db);
140 self.catalogs.insert(catalog_name.clone(), catalog);
141 if is_first {
142 self.set_current_catalog(catalog_name).await?;
143 self.set_current_database(default_db).await?;
144 }
145 Ok(())
146 }
147
148 /// Sets the current catalog for unqualified table references.
149 pub async fn set_current_catalog(&mut self, catalog_name: impl Into<String>) -> DFResult<()> {

Calls 7

register_table_functionsFunction · 0.85
insertMethod · 0.80
is_emptyMethod · 0.45
get_databaseMethod · 0.45
create_databaseMethod · 0.45
set_current_catalogMethod · 0.45
set_current_databaseMethod · 0.45