Skip to content

Commit b84ddfd

Browse files
authored
chore: Add drop table test on create_drop.rs (#17219)
Signed-off-by: cancaicai <2356672992@qq.com>
1 parent a5c242c commit b84ddfd

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

datafusion/core/src/execution/context/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ impl SessionContext {
914914
..
915915
} = cmd;
916916

917-
// sqlparser doesnt accept database / catalog as parameter to CREATE SCHEMA
917+
// sqlparser doesn't accept database / catalog as parameter to CREATE SCHEMA
918918
// so for now, we default to default catalog
919919
let tokens: Vec<&str> = schema_name.split('.').collect();
920920
let (catalog, schema_name) = match tokens.len() {

datafusion/core/tests/sql/create_drop.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,26 @@ async fn create_external_table_with_ddl() -> Result<()> {
6666

6767
Ok(())
6868
}
69+
70+
#[tokio::test]
71+
async fn create_drop_table() -> Result<()> {
72+
let ctx = SessionContext::new();
73+
74+
let sql = "CREATE TABLE dt (a_id integer, a_str string, a_bool boolean);";
75+
ctx.sql(sql).await.unwrap();
76+
77+
let cat = ctx.catalog("datafusion").unwrap();
78+
let schema = cat.schema("public").unwrap();
79+
80+
let exists = schema.table_exist("dt");
81+
assert!(exists, "Table should have been created!");
82+
83+
// Drop the table
84+
let sql = "DROP TABLE dt;";
85+
ctx.sql(sql).await.unwrap();
86+
87+
let exists = schema.table_exist("dt");
88+
assert!(!exists, "Table should have been dropped!");
89+
90+
Ok(())
91+
}

0 commit comments

Comments
 (0)