Skip to content

Commit

Permalink
chore/binder: add delete test and complete drop test
Browse files Browse the repository at this point in the history
Signed-off-by: caicancai <[email protected]>
  • Loading branch information
caicancai committed Nov 15, 2023
1 parent 73b2c79 commit a758175
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
27 changes: 27 additions & 0 deletions src/binder/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
7 changes: 6 additions & 1 deletion src/binder/drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ impl Binder {
mod tests {
use std::sync::Arc;

use crate::binder::Binder;
use crate::catalog::RootCatalog;
use crate::parser::parse;

Expand All @@ -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));
}
}
}

0 comments on commit a758175

Please sign in to comment.