You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/04/05 20:23:47 UTC

[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #2094: Add CREATE DATABASE command to SQL

alamb commented on code in PR #2094:
URL: https://github.com/apache/arrow-datafusion/pull/2094#discussion_r843227531


##########
datafusion/core/src/logical_plan/plan.rs:
##########
@@ -363,6 +374,8 @@ pub enum LogicalPlan {
     CreateMemoryTable(CreateMemoryTable),
     /// Creates a new catalog schema.
     CreateCatalogSchema(CreateCatalogSchema),
+    /// Creates a new catalog schema.

Review Comment:
   ```suggestion
       /// Creates a new catalog (aka "Database").
   ```



##########
datafusion/core/src/logical_plan/plan.rs:
##########
@@ -193,7 +193,18 @@ pub struct CreateExternalTable {
 pub struct CreateCatalogSchema {
     /// The table schema
     pub schema_name: String,
-    /// The table name
+    /// Do nothing (except issuing a notice) if a schema with the same name already exists
+    pub if_not_exists: bool,
+    /// Empty schema
+    pub schema: DFSchemaRef,
+}
+
+/// Creates a catalog.

Review Comment:
   ```suggestion
   /// Creates a catalog (aka "Database")
   ```



##########
datafusion/core/src/execution/context.rs:
##########
@@ -3221,6 +3257,32 @@ mod tests {
         Ok(())
     }
 
+    #[tokio::test]
+    async fn sql_create_catalog() -> Result<()> {
+        // the information schema used to introduce cyclic Arcs
+        let ctx = SessionContext::with_config(
+            SessionConfig::new().with_information_schema(true),
+        );
+
+        // Create catalog
+        ctx.sql("CREATE DATABASE test").await?.collect().await?;
+
+        // Create schema
+        ctx.sql("CREATE SCHEMA test.abc").await?.collect().await?;

Review Comment:
   this is cool 👍 



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org