Apache DataFusion SQL Query Engine
chore: Add drop table test on create_drop.rs (#17219)
Cancai Caib84ddfde0689
diff --git a/datafusion/core/src/execution/context/mod.rs b/datafusion/core/src/execution/context/mod.rsindex bbe33c5179..de1d40dda3 100644--- a/datafusion/core/src/execution/context/mod.rs+++ b/datafusion/core/src/execution/context/mod.rs@@ -914,7 +914,7 @@ impl SessionContext {..} = cmd;- // sqlparser doesnt accept database / catalog as parameter to CREATE SCHEMA+ // sqlparser doesn't accept database / catalog as parameter to CREATE SCHEMA// so for now, we default to default cataloglet tokens: Vec<&str> = schema_name.split('.').collect();let (catalog, schema_name) = match tokens.len() {diff --git a/datafusion/core/tests/sql/create_drop.rs b/datafusion/core/tests/sql/create_drop.rsindex b35e614a46..4a60a79ff5 100644--- a/datafusion/core/tests/sql/create_drop.rs+++ b/datafusion/core/tests/sql/create_drop.rs@@ -66,3 +66,26 @@ async fn create_external_table_with_ddl() -> Result<()> {Ok(())}++#[tokio::test]+async fn create_drop_table() -> Result<()> {+ let ctx = SessionContext::new();++ let sql = "CREATE TABLE dt (a_id integer, a_str string, a_bool boolean);";+ ctx.sql(sql).await.unwrap();++ let cat = ctx.catalog("datafusion").unwrap();+ let schema = cat.schema("public").unwrap();++ let exists = schema.table_exist("dt");+ assert!(exists, "Table should have been created!");++ // Drop the table+ let sql = "DROP TABLE dt;";+ ctx.sql(sql).await.unwrap();++ let exists = schema.table_exist("dt");+ assert!(!exists, "Table should have been dropped!");++ Ok(())+}