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

Method set_current_catalog

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

Sets the current catalog for unqualified table references.

(&mut self, catalog_name: impl Into<String>)

Source from the content-addressed store, hash-verified

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<()> {
150 let catalog_name = catalog_name.into();
151 if !self.catalogs.contains_key(&catalog_name) {
152 return Err(DataFusionError::Plan(format!(
153 "Unknown catalog '{catalog_name}'"
154 )));
155 }
156 if catalog_name.contains('\'') {
157 return Err(DataFusionError::Plan(
158 "Catalog name must not contain single quotes".to_string(),
159 ));
160 }
161 self.ctx
162 .sql(&format!(
163 "SET datafusion.catalog.default_catalog = '{catalog_name}'"
164 ))
165 .await?;
166 Ok(())
167 }
168
169 /// Sets the current database for unqualified table references.
170 pub async fn set_current_database(&self, database_name: &str) -> DFResult<()> {

Callers 2

register_catalogMethod · 0.45
test_set_current_catalogFunction · 0.45

Calls 3

containsMethod · 0.80
PlanClass · 0.50
sqlMethod · 0.45

Tested by 1

test_set_current_catalogFunction · 0.36