diff --git a/dbms/tests/queries/0_stateless/00072_defaulted_columns.reference b/dbms/tests/queries/0_stateless/00072_defaulted_columns.reference new file mode 100644 index 00000000000..36893cb3f76 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00072_defaulted_columns.reference @@ -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 diff --git a/dbms/tests/queries/0_stateless/00072_defaulted_columns.sql b/dbms/tests/queries/0_stateless/00072_defaulted_columns.sql new file mode 100644 index 00000000000..d27c4b50d31 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00072_defaulted_columns.sql @@ -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;