From a758175c5a0205c5aade80dd075895cca4c266fd Mon Sep 17 00:00:00 2001 From: caicancai <2356672992@qq.com> Date: Wed, 15 Nov 2023 18:39:52 +0800 Subject: [PATCH] chore/binder: add delete test and complete drop test Signed-off-by: caicancai <2356672992@qq.com> --- src/binder/delete.rs | 27 +++++++++++++++++++++++++++ src/binder/drop.rs | 7 ++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/binder/delete.rs b/src/binder/delete.rs index 6c570ed44..1a2c8b261 100644 --- a/src/binder/delete.rs +++ b/src/binder/delete.rs @@ -24,3 +24,30 @@ impl Binder { Ok(self.egraph.add(Node::Delete([table_id, filter]))) } } + +#[cfg(test)] +mod tests { + use std::sync::Arc; + + use super::*; + use crate::binder::Binder; + use crate::catalog::{ColumnCatalog, RootCatalog}; + use crate::parser::parse; + + #[test] + fn bind_test_subquery() { + let catalog = Arc::new(RootCatalog::new()); + let col_desc = DataTypeKind::Int32.not_null().to_column("a".into()); + let col_catalog = ColumnCatalog::new(0, col_desc); + catalog + .add_table(0, "t".into(), vec![col_catalog], false, vec![]) + .unwrap(); + + let stmts = parse("delete from t where a").unwrap(); + let mut binder = Binder::new(catalog); + for stmt in stmts { + let plan = binder.bind(stmt).unwrap(); + println!("{}", plan.pretty(10)); + } + } +} diff --git a/src/binder/drop.rs b/src/binder/drop.rs index 02368f194..5426c9970 100644 --- a/src/binder/drop.rs +++ b/src/binder/drop.rs @@ -84,6 +84,7 @@ impl Binder { mod tests { use std::sync::Arc; + use crate::binder::Binder; use crate::catalog::RootCatalog; use crate::parser::parse; @@ -95,6 +96,10 @@ mod tests { .unwrap(); let stmts = parse("drop table mytable").unwrap(); - println!("{:?}", stmts) + let mut binder = Binder::new(catalog); + for stmt in stmts { + let plan = binder.bind(stmt).unwrap(); + println!("{}", plan.pretty(10)); + } } }