Added test.

This commit is contained in:
Nikolai Kochetov 2020-04-30 18:39:09 +03:00 committed by Alexey Milovidov
parent 086831e74c
commit 74b5e19fa5
2 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,21 @@
0 2
1 2
0 2
1 2
0 2
1 2
the rows get inserted
2020-01-01 0 0
2020-01-01 0 2
2020-01-01 0 4
no new rows
2020-01-01 0 0
2020-01-01 0 2
2020-01-01 0 4
the rows get inserted
2020-01-01 0 0
2020-01-01 0 2
2020-01-01 0 4
2020-01-06 5 0
2020-01-06 5 2
2020-01-06 5 4

View File

@ -0,0 +1,26 @@
create table src_table Engine=Memory as system.numbers;
CREATE MATERIALIZED VIEW dst_mv Engine=Memory as select *, (SELECT count() FROM src_table) AS cnt FROM src_table;
insert into src_table select * from numbers(2);
insert into src_table select * from numbers(2);
insert into src_table select * from numbers(2);
select * from dst_mv;
CREATE TABLE dest_table (`Date` Date, `Id` UInt64, `Units` Float32) ENGINE = Memory;
create table left_table as dest_table;
create table right_table as dest_table;
insert into right_table select toDate('2020-01-01') + number, number, number / 2 from numbers(10);
CREATE MATERIALIZED VIEW dest_table_mv TO dest_table as select * FROM (SELECT * FROM left_table) AS t1 INNER JOIN (WITH (SELECT DISTINCT Date FROM left_table LIMIT 1) AS dt SELECT * FROM right_table WHERE Date = dt) AS t2 USING (Date, Id);
insert into left_table select toDate('2020-01-01'), 0, number * 2 from numbers(3);
select 'the rows get inserted';
select * from dest_table;
insert into left_table select toDate('2020-01-01'), 5, number * 2 from numbers(3);
select 'no new rows';
select * from dest_table;
truncate table left_table;
insert into left_table select toDate('2020-01-01') + 5, 5, number * 2 from numbers(3);
select 'the rows get inserted';
select * from dest_table;