Sets the current catalog for unqualified table references.
(&mut self, catalog_name: impl Into<String>)
| 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<()> { |