mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Added test.
This commit is contained in:
parent
086831e74c
commit
74b5e19fa5
21
tests/queries/0_stateless/01268_mv_scalars.reference
Normal file
21
tests/queries/0_stateless/01268_mv_scalars.reference
Normal 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
|
26
tests/queries/0_stateless/01268_mv_scalars.sql
Normal file
26
tests/queries/0_stateless/01268_mv_scalars.sql
Normal 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;
|
Loading…
Reference in New Issue
Block a user