Skip to content

Commit 8443464

Browse files
committed
style(db): test_crud_sql support batch display
1 parent 89d08f9 commit 8443464

3 files changed

Lines changed: 15 additions & 44 deletions

File tree

src/binder/select.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,8 @@ mod tests {
324324
use super::*;
325325
use crate::binder::BinderContext;
326326
use crate::catalog::{ColumnCatalog, ColumnDesc, RootCatalog};
327-
use crate::expression::agg::AggKind;
328-
use crate::expression::BinaryOperator::{Gt, Minus};
329-
use crate::expression::ScalarExpression::{AggCall, Binary, ColumnRef, Constant, InputRef};
330327
use crate::planner::LogicalPlan;
331-
use crate::planner::operator::aggregate::AggregateOperator;
332328
use crate::types::LogicalType::Integer;
333-
use crate::types::value::DataValue::Int32;
334329

335330
fn test_root_catalog() -> Result<RootCatalog> {
336331
let mut root = RootCatalog::new();

src/db.rs

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -45,45 +45,18 @@ impl Database {
4545
/// Limit(1)
4646
/// Project(a,b)
4747
let logical_plan = binder.bind(&stmts[0])?;
48-
println!("logic plan: {:#?}", logical_plan);
48+
// println!("logic plan: {:#?}", logical_plan);
4949

5050
let mut builder = PhysicalPlanBuilder::new();
5151
let operator = builder.build_plan(&logical_plan)?;
52-
println!("operator: {:#?}", operator);
52+
// println!("operator: {:#?}", operator);
5353

5454
let storage = StorageImpl::InMemoryStorage(self.storage.clone());
5555
let executor = VolcanoExecutor::new(storage);
5656

5757
let mut stream = executor.build(operator);
5858

5959
Ok(VolcanoExecutor::try_collect(&mut stream).await?)
60-
61-
// // let physical_planner = PhysicalPlaner::default();
62-
// // let executor_builder = ExecutorBuilder::new(self.env.clone());
63-
//
64-
// // let physical_plan = physical_planner.plan(logical_plan)?;
65-
// // let executor = executor_builder.build(physical_plan)?;
66-
// // futures::executor::block_on(executor).unwrap();
67-
//
68-
// /// THE FOLLOWING CODE IS FOR TESTING ONLY
69-
// /// THE FINAL CODE WILL BE IN executor MODULE
70-
// if let LogicalPlan::CreateTable(plan) = logical_plan {
71-
// let mut columns = Vec::new();
72-
// plan.columns.iter().for_each(|c| {
73-
// columns.push(ColumnCatalog::new(c.0.clone(), c.1, c.2.clone()));
74-
// });
75-
// let table_name = plan.table_name.clone();
76-
// // columns->batch record
77-
// let mut data = Vec::new();
78-
//
79-
// columns.iter().for_each(|c| {
80-
// let batch = RecordBatch::new_empty(Arc::new(Schema::new(vec![c.to_field()])));
81-
// data.push(batch);
82-
// });
83-
//
84-
// self.storage
85-
// .create_table(IdGenerator::build(), table_name.as_str(), data)?;
86-
// }
8760
}
8861
}
8962

@@ -174,19 +147,22 @@ mod test {
174147
Ok(())
175148
})
176149
}
150+
177151
#[test]
178152
fn test_crud_sql() -> anyhow::Result<()> {
179-
let database = Database::new_on_mem();
153+
let kipsql = Database::new_on_mem();
180154

181155
tokio_test::block_on(async move {
182-
let _ = database.run("create table t1 (a int, b boolean)").await?;
183-
let _ = database.run("insert into t1 values (1, true), (2, false)").await?;
184-
let vec_batch = database.run("select * from t1 where a = 1 or b = false").await?;
185-
186-
let table = database.storage
187-
.get_catalog()
188-
.get_table(0).unwrap().clone();
189-
print_batches(&vec_batch)?;
156+
let _ = kipsql.run("create table t1 (a int, b int)").await?;
157+
let _ = kipsql.run("insert into t1 values (1, 2), (3, 4)").await?;
158+
159+
println!("full:");
160+
let vec_batch_full_fields = kipsql.run("select * from t1").await?;
161+
print_batches(&vec_batch_full_fields)?;
162+
163+
println!("projection_and_filter:");
164+
let vec_batch_projection_a = kipsql.run("select a from t1 where a != 3 and a < b ").await?;
165+
print_batches(&vec_batch_projection_a)?;
190166

191167
Ok(())
192168
})

src/execution_v1/volcano_executor/table_scan.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ impl TableScan {
1313
pub async fn execute(plan: PhysicalTableScan, storage: impl Storage) {
1414
// TODO: sort_fields, pre_where, limit
1515
let ScanOperator { table_ref_id, .. } = plan.base;
16-
println!("ref id: {}", table_ref_id);
16+
1717
let table = storage.get_table(table_ref_id)?;
1818
let mut transaction = table.read(
1919
None,

0 commit comments

Comments
 (0)