ClickHouse/tests/queries/0_stateless/01157_replace_table.sql

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

54 lines
2.2 KiB
MySQL
Raw Normal View History

2021-09-12 12:35:27 +00:00
-- Tags: no-ordinary-database
2021-07-01 13:21:38 +00:00
drop table if exists t;
drop table if exists dist;
drop table if exists buf;
drop table if exists join;
select 'test flush on replace';
create table t (n UInt64, s String default 's' || toString(n)) engine=Memory;
create table dist (n int) engine=Distributed(test_shard_localhost, currentDatabase(), t);
create table buf (n int) engine=Buffer(currentDatabase(), dist, 1, 10, 100, 10, 100, 1000, 1000);
2021-07-02 16:39:55 +00:00
system stop distributed sends dist;
2021-07-01 13:21:38 +00:00
insert into buf values (1);
replace table buf (n int) engine=Distributed(test_shard_localhost, currentDatabase(), dist);
replace table dist (n int) engine=Buffer(currentDatabase(), t, 1, 10, 100, 10, 100, 1000, 1000);
2021-07-02 16:39:55 +00:00
system stop distributed sends buf;
2021-07-01 13:21:38 +00:00
insert into buf values (2);
replace table buf (n int) engine=Buffer(currentDatabase(), dist, 1, 10, 100, 10, 100, 1000, 1000);
replace table dist (n int) engine=Distributed(test_shard_localhost, currentDatabase(), t);
2021-07-02 16:39:55 +00:00
system stop distributed sends dist;
2021-07-01 13:21:38 +00:00
insert into buf values (3);
replace table buf (n int) engine=Null;
replace table dist (n int) engine=Null;
select * from t order by n;
select 'exception on create and fill';
-- table is not created if select fails
create or replace table join engine=Join(ANY, INNER, n) as select * from t where throwIf(n); -- { serverError FUNCTION_THROW_IF_VALUE_IS_NON_ZERO }
2021-07-01 13:21:38 +00:00
select count() from system.tables where database=currentDatabase() and name='join';
-- table is created and filled
create or replace table join engine=Join(ANY, INNER, n) as select * from t;
select * from numbers(10) as t any join join on t.number=join.n order by n;
-- table is not replaced if select fails
insert into t(n) values (4);
replace table join engine=Join(ANY, INNER, n) as select * from t where throwIf(n); -- { serverError FUNCTION_THROW_IF_VALUE_IS_NON_ZERO }
2021-07-01 13:21:38 +00:00
select * from numbers(10) as t any join join on t.number=join.n order by n;
-- table is replaced
replace table join engine=Join(ANY, INNER, n) as select * from t;
select * from numbers(10) as t any join join on t.number=join.n order by n;
select name from system.tables where database=currentDatabase() order by name;
drop table t;
drop table dist;
drop table buf;
drop table join;