dbms: add tests for defaulted columns. [#METR-12739]

This commit is contained in:
Andrey Mironov 2014-11-11 19:30:17 +03:00
parent 65629ef560
commit ccc770e5ab
2 changed files with 77 additions and 0 deletions

View File

@ -0,0 +1,41 @@
col1 UInt8 DEFAULT 0
col1 UInt32
col2 UInt64 DEFAULT col1 + 1
col3 UInt64 MATERIALIZED col1 + 2
col4 UInt64 ALIAS col1 + 3
10 11
12 13
payload String
date Date MATERIALIZED today()
key UInt64 MATERIALIZED 0 * rand()
hello clickhouse
payload String
date Date MATERIALIZED today()
key UInt64 MATERIALIZED 0 * rand()
payload_length UInt64 MATERIALIZED length(payload)
hello clickhouse 16
some string 11
hello clickhouse 16
hello clickhouse 16
some string 11
payload String
payload_length UInt64 DEFAULT length(payload)
date Date MATERIALIZED today()
key UInt64 MATERIALIZED 0 * rand()
hello clickhouse 16
some string 11
payload String
payload_length UInt16 DEFAULT length(payload) % 65535
date Date MATERIALIZED today()
key UInt64 MATERIALIZED 0 * rand()
hello clickhouse 16
some string 11
payload String
payload_length UInt16 DEFAULT toUInt16(length(payload))
date Date MATERIALIZED today()
key UInt64 MATERIALIZED 0 * rand()
payload String
date Date MATERIALIZED today()
key UInt64 MATERIALIZED 0 * rand()
hello clickhouse
some string

View File

@ -0,0 +1,36 @@
drop table if exists defaulted_test;
create table defaulted_test (col1 default 0) engine=Memory;
desc table defaulted_test;
drop table defaulted_test;
create table defaulted_test (col1 UInt32, col2 default col1 + 1, col3 materialized col1 + 2, col4 alias col1 + 3) engine=Memory;
desc table defaulted_test;
insert into defaulted_test (col1) values (10);
select * from defaulted_test;
select col3, col4 from defaulted_test;
drop table defaulted_test;
create table defaulted_test (payload String, date materialized today(), key materialized 0 * rand()) engine=MergeTree(date, key, 8192);
desc table defaulted_test;
insert into defaulted_test (payload) values ('hello clickhouse');
select * from defaulted_test;
alter table defaulted_test add column payload_length materialized length(payload);
desc table defaulted_test;
select *, payload_length from defaulted_test;
insert into defaulted_test (payload) values ('some string');
select *, payload_length from defaulted_test;
optimize table defaulted_test;
select *, payload_length from defaulted_test;
alter table defaulted_test modify column payload_length default length(payload);
desc table defaulted_test;
select * from defaulted_test;
alter table defaulted_test modify column payload_length default length(payload) % 65535;
desc table defaulted_test;
select * from defaulted_test;
alter table defaulted_test modify column payload_length UInt16 default length(payload);
desc table defaulted_test;
alter table defaulted_test drop column payload_length;
desc table defaulted_test;
select * from defaulted_test;
drop table defaulted_test;