Sets the current database for unqualified table references.
(&self, database_name: &str)
| 168 | |
| 169 | /// Sets the current database for unqualified table references. |
| 170 | pub async fn set_current_database(&self, database_name: &str) -> DFResult<()> { |
| 171 | if database_name.contains('\'') { |
| 172 | return Err(DataFusionError::Plan( |
| 173 | "Database name must not contain single quotes".to_string(), |
| 174 | )); |
| 175 | } |
| 176 | self.ctx |
| 177 | .sql(&format!( |
| 178 | "SET datafusion.catalog.default_schema = '{database_name}'" |
| 179 | )) |
| 180 | .await?; |
| 181 | Ok(()) |
| 182 | } |
| 183 | |
| 184 | /// Returns a reference to the inner [`SessionContext`]. |
| 185 | pub fn ctx(&self) -> &SessionContext { |