Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
xxhZs committed Jun 5, 2024
1 parent 03d1383 commit 759b4c9
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 13 deletions.
146 changes: 146 additions & 0 deletions e2e_test/streaming/changed_log.slt
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 0 additions & 2 deletions src/frontend/src/binder/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion src/frontend/src/binder/relation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 })))
},
}
Expand Down
2 changes: 0 additions & 2 deletions src/frontend/src/planner/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down Expand Up @@ -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() {
Expand Down
5 changes: 1 addition & 4 deletions src/frontend/src/planner/set_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ impl Planner {
order: &[ColumnOrder],
) -> Result<PlanRef> {
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 {
Expand Down
4 changes: 0 additions & 4 deletions src/stream/src/executor/row_id_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 759b4c9

Please sign in to comment.