matthewmturner commented on a change in pull request #1959:
URL: https://github.com/apache/arrow-datafusion/pull/1959#discussion_r824183466



##########
File path: datafusion/src/execution/context.rs
##########
@@ -283,6 +282,61 @@ impl ExecutionContext {
                     Ok(Arc::new(DataFrameImpl::new(self.state.clone(), &plan)))
                 }
             }
+            LogicalPlan::CreateCatalogSchema(CreateCatalogSchema {
+                schema_name,
+                if_not_exists,
+                ..
+            }) => {
+                // sqlparser doesnt accept database / catalog as parameter to 
CREATE SCHEMA
+                // so for now, we default to "datafusion" catalog
+                let default_catalog = "datafusion";
+                let catalog = self.catalog(default_catalog).ok_or_else(|| {
+                    DataFusionError::Execution(String::from(
+                        "Missing 'datafusion' catalog",
+                    ))
+                })?;
+
+                let schema = catalog.schema(&schema_name);
+
+                match (if_not_exists, schema) {
+                    //
+                    (true, Some(_)) => {
+                        println!("Schema '{:?}' already exists", &schema_name);
+                        let plan = LogicalPlanBuilder::empty(false).build()?;
+                        Ok(Arc::new(DataFrameImpl::new(self.state.clone(), 
&plan)))
+                    }
+                    (true, None) | (false, None) => {
+                        println!("Creating schema {:?}", schema_name);
+                        let schema = Arc::new(MemorySchemaProvider::new());
+                        let plan = LogicalPlanBuilder::empty(false).build()?;
+                        schema.register_table(
+                            "test".into(),
+                            Arc::new(DataFrameImpl::new(self.state.clone(), 
&plan)),
+                        )?;
+                        let schem_reg_res = 
catalog.register_schema(&schema_name, schema);

Review comment:
       (i know theres a lot of fluff right now that im using for debugging 
purposes)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to