From 759b4c99c863202654000e55da27451912f6d600 Mon Sep 17 00:00:00 2001 From: xxhZs <1060434431@qq.com> Date: Wed, 5 Jun 2024 18:28:49 +0800 Subject: [PATCH] add test --- e2e_test/streaming/changed_log.slt | 146 ++++++++++++++++++++++++ src/frontend/src/binder/query.rs | 2 - src/frontend/src/binder/relation/mod.rs | 1 - src/frontend/src/planner/select.rs | 2 - src/frontend/src/planner/set_expr.rs | 5 +- src/stream/src/executor/row_id_gen.rs | 4 - 6 files changed, 147 insertions(+), 13 deletions(-) create mode 100644 e2e_test/streaming/changed_log.slt diff --git a/e2e_test/streaming/changed_log.slt b/e2e_test/streaming/changed_log.slt new file mode 100644 index 000000000000..be502683d9e7 --- /dev/null +++ b/e2e_test/streaming/changed_log.slt @@ -0,0 +1,146 @@ +statement ok +SET RW_IMPLICIT_FLUSH TO true; + +statement ok +create table t1 (v1 int, v2 int); + +statement ok +create table t2 (v1 int, v2 int); + +statement ok +create table t3 (v1 int primary key, v2 int); + +statement ok +create materialized view mv1 as with sub as changedlog from t1 select * from sub; + +statement ok +create materialized view mv2 as with sub as changedlog from t2 select * from sub; + +statement ok +create materialized view mv3 as with sub as changedlog from t1 select v1, v2 from sub; + +statement ok +create materialized view mv4 as with sub1 as changedlog from t1, sub2 as changedlog from t2 +select sub1.v1 as v11, sub1.v2 as v12, sub2.v1 as v21, sub2.v2 as v22 from sub1 inner join sub2 on sub1.v1 = sub2.v1; + +statement ok +create materialized view mv5 as with sub1 as changedlog from t1, sub2 as changedlog from t2 +select sub1.v1 as v11, sub1.v2 as v12, sub2.v1 as v21, sub2.v2 as v22, sub1.op as op1, sub2.op as op2 from sub1 inner join sub2 on sub1.v1 = sub2.v1; + +statement ok +create materialized view mv6 as with sub as changedlog from t3 select * from sub; + +statement ok +insert into t1 values(1,1),(2,2); + +statement ok +insert into t2 values(1,10),(2,20); + +statement ok +insert into t3 values(5,5),(6,6); + +statement ok +update t1 set v2 = 100 where v1 = 1; + +statement ok +update t2 set v2 = 100 where v1 = 1; + +statement ok +update t3 set v2 = 500 where v1 = 5; + +statement ok +delete from t1 where v1 = 2; + +query III rowsort +select * from mv1 order by v1; +---- +1 1 1 +1 1 4 +1 100 3 +2 2 1 +2 2 2 + +query III rowsort +select * from mv2 order by v1; +---- +1 10 1 +1 10 4 +1 100 3 +2 20 1 + +query III rowsort +select * from mv3 order by v1; +---- +1 1 +1 1 +1 100 +2 2 +2 2 + +query III rowsort +select * from mv4 order by v11,v21; +---- +1 1 1 10 +1 1 1 10 +1 1 1 10 +1 1 1 10 +1 1 1 100 +1 1 1 100 +1 100 1 10 +1 100 1 10 +1 100 1 100 +2 2 2 20 +2 2 2 20 + + +query III rowsort +select * from mv5 order by v11,v21; +---- +1 1 1 10 1 1 +1 1 1 10 1 4 +1 1 1 10 4 1 +1 1 1 10 4 4 +1 1 1 100 1 3 +1 1 1 100 4 3 +1 100 1 10 3 1 +1 100 1 10 3 4 +1 100 1 100 3 3 +2 2 2 20 1 1 +2 2 2 20 2 1 + +query III rowsort +select * from mv6 order by v1; +---- +5 5 1 +5 5 4 +5 500 3 +6 6 1 + + +statement ok +drop materialized view mv6; + +statement ok +drop materialized view mv5; + +statement ok +drop materialized view mv4; + +statement ok +drop materialized view mv3; + +statement ok +drop materialized view mv2; + +statement ok +drop materialized view mv1; + + +statement ok +drop table t3; + +statement ok +drop table t2; + +statement ok +drop table t1; \ No newline at end of file diff --git a/src/frontend/src/binder/query.rs b/src/frontend/src/binder/query.rs index 5814a2316748..533d4a0208f6 100644 --- a/src/frontend/src/binder/query.rs +++ b/src/frontend/src/binder/query.rs @@ -324,7 +324,6 @@ impl Binder { self.bind_rcte(with, entry, *left, *right, all)?; } else if let Some(query) = query { let bound_query = self.bind_query(query)?; - println!("ccc3 {:?}", self.context.columns); self.context.cte_to_relation.insert( table_name, Rc::new(RefCell::new(BindingCte { @@ -346,7 +345,6 @@ impl Binder { None, )?; self.pop_context()?; - println!("ddd {:?}", self.context.columns); self.context.cte_to_relation.insert( table_name, Rc::new(RefCell::new(BindingCte { diff --git a/src/frontend/src/binder/relation/mod.rs b/src/frontend/src/binder/relation/mod.rs index 40acf44eb4db..2cdf3ea07db4 100644 --- a/src/frontend/src/binder/relation/mod.rs +++ b/src/frontend/src/binder/relation/mod.rs @@ -399,7 +399,6 @@ impl Binder { table_name.clone(), Some(original_alias), )?; - println!("self.context.columns: {:?}", self.context.columns); Ok(Relation::Share(Box::new(BoundShare { share_id, input }))) }, } diff --git a/src/frontend/src/planner/select.rs b/src/frontend/src/planner/select.rs index 4341876f57eb..70bd358f7332 100644 --- a/src/frontend/src/planner/select.rs +++ b/src/frontend/src/planner/select.rs @@ -95,7 +95,6 @@ impl Planner { None => self.create_dummy_values(), Some(t) => self.plan_relation(t)?, }; - println!("root {:?}", root.schema()); // Plan the WHERE clause. if let Some(where_clause) = where_clause { root = self.plan_where(root, where_clause)?; @@ -155,7 +154,6 @@ impl Planner { let need_restore_select_items = select_items.len() > original_select_items_len; root = LogicalProjectSet::create(root, select_items.clone()); - println!("root1 {:?},{:?}", root.schema(), select_items); if matches!(&distinct, BoundDistinct::DistinctOn(_)) { root = if order.is_empty() { diff --git a/src/frontend/src/planner/set_expr.rs b/src/frontend/src/planner/set_expr.rs index 7d1edd69cde6..e2ff43a2c211 100644 --- a/src/frontend/src/planner/set_expr.rs +++ b/src/frontend/src/planner/set_expr.rs @@ -28,10 +28,7 @@ impl Planner { order: &[ColumnOrder], ) -> Result { match set_expr { - BoundSetExpr::Select(s) => { - println!("BoundSetExpr::Select(s) {:?}", s); - self.plan_select(*s, extra_order_exprs, order) - } + BoundSetExpr::Select(s) => self.plan_select(*s, extra_order_exprs, order), BoundSetExpr::Values(v) => self.plan_values(*v), BoundSetExpr::Query(q) => Ok(self.plan_query(*q)?.into_unordered_subplan()), BoundSetExpr::SetOperation { diff --git a/src/stream/src/executor/row_id_gen.rs b/src/stream/src/executor/row_id_gen.rs index d62239a0051c..2da75389fd9f 100644 --- a/src/stream/src/executor/row_id_gen.rs +++ b/src/stream/src/executor/row_id_gen.rs @@ -96,10 +96,6 @@ impl RowIdGenExecutor { Message::Chunk(chunk) => { // For chunk message, we fill the row id column and then yield it. let (ops, mut columns, bitmap) = chunk.into_inner(); - println!( - "RowIdGenExecutor: execute_inner: ops: {:?}", - columns[self.row_id_index] - ); columns[self.row_id_index] = self.gen_row_id_column_by_op(&columns[self.row_id_index], &ops, &bitmap); yield Message::Chunk(StreamChunk::with_visibility(ops, columns, bitmap));