You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "jaylmiller (via GitHub)" <gi...@apache.org> on 2023/04/22 19:13:47 UTC

[GitHub] [arrow-datafusion] jaylmiller commented on a diff in pull request #6096: Support DROP SCHEMA statements

jaylmiller commented on code in PR #6096:
URL: https://github.com/apache/arrow-datafusion/pull/6096#discussion_r1174452325


##########
datafusion/core/tests/sql/create_drop.rs:
##########
@@ -73,3 +73,40 @@ async fn create_external_table_with_ddl() -> Result<()> {
 
     Ok(())
 }
+
+#[tokio::test]
+async fn drop_schema_empty() -> Result<()> {
+    let ctx = SessionContext::new();
+    ctx.sql("CREATE SCHEMA datafusion.test_schema").await?;
+    ctx.sql("DROP SCHEMA datafusion.test_schema").await?;
+
+    ctx.sql("CREATE SCHEMA test_schema").await?;
+    ctx.sql("DROP SCHEMA test_schema").await?;
+    ctx.sql("DROP SCHEMA IF EXISTS test_schema").await?;
+
+    assert!(
+        ctx.sql("DROP SCHEMA test_schema").await.is_err(),
+        "dropping non-existent schema should fail"
+    );
+    Ok(())
+}
+
+#[tokio::test]
+async fn drop_schema_cascade() -> Result<()> {
+    let ctx = SessionContext::new();
+    ctx.sql("CREATE SCHEMA test_schema").await?;
+    ctx.sql("CREATE TABLE test_schema.t1 (i int)").await?;
+
+    assert!(
+        ctx.sql("DROP SCHEMA test_schema").await.is_err(),
+        "drop without cascade should fail"
+    );
+    ctx.sql("DROP SCHEMA test_schema CASCADE").await?;
+
+    assert!(
+        ctx.sql("SELECT 1 from test_schema.t1").await.is_err(),
+        "table should not be queryable after cascading drop"
+    );
+
+    Ok(())
+}

Review Comment:
   This demonstrates what kind of SQL statements are now supported



-- 
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