2021-09-12 12:35:27 +00:00
|
|
|
-- Tags: no-fasttest
|
|
|
|
|
2019-03-22 16:15:44 +00:00
|
|
|
SET input_format_defaults_for_omitted_fields=1;
|
2018-11-14 15:23:00 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
DROP TABLE IF EXISTS defaults;
|
|
|
|
CREATE TABLE defaults
|
2018-07-11 16:24:29 +00:00
|
|
|
(
|
|
|
|
x UInt32,
|
|
|
|
y UInt32,
|
2018-07-12 14:33:57 +00:00
|
|
|
a DEFAULT x + y,
|
2019-08-01 19:17:49 +00:00
|
|
|
b Float32 DEFAULT round(log(1 + x + y), 5),
|
2018-07-12 10:03:49 +00:00
|
|
|
c UInt32 DEFAULT 42,
|
|
|
|
e MATERIALIZED x + y,
|
|
|
|
f ALIAS x + y
|
2019-03-22 15:39:01 +00:00
|
|
|
) ENGINE = MergeTree ORDER BY x;
|
2018-07-11 16:24:29 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
INSERT INTO defaults FORMAT JSONEachRow {"x":1, "y":1};
|
|
|
|
INSERT INTO defaults (x, y) SELECT x, y FROM defaults LIMIT 1;
|
|
|
|
INSERT INTO defaults FORMAT JSONEachRow {"x":2, "y":2, "c":2};
|
|
|
|
INSERT INTO defaults FORMAT JSONEachRow {"x":3, "y":3, "a":3, "b":3, "c":3};
|
|
|
|
INSERT INTO defaults FORMAT JSONEachRow {"x":4} {"y":5, "c":5} {"a":6, "b":6, "c":6};
|
2018-07-11 16:24:29 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
SELECT * FROM defaults ORDER BY (x, y);
|
2019-03-22 15:39:01 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
ALTER TABLE defaults ADD COLUMN n Nested(a UInt64, b String);
|
|
|
|
INSERT INTO defaults FORMAT JSONEachRow {"x":7, "y":7, "n.a":[1,2], "n.b":["a","b"]};
|
|
|
|
SELECT * FROM defaults WHERE x = 7 FORMAT JSONEachRow;
|
2019-03-22 15:39:01 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
ALTER TABLE defaults ADD COLUMN n.c Array(UInt8) DEFAULT arrayMap(x -> 0, n.a) AFTER n.a;
|
|
|
|
INSERT INTO defaults FORMAT JSONEachRow {"x":8, "y":8, "n.a":[3,4], "n.b":["c","d"]};
|
|
|
|
INSERT INTO defaults FORMAT JSONEachRow {"x":9, "y":9};
|
|
|
|
SELECT * FROM defaults WHERE x > 7 ORDER BY x FORMAT JSONEachRow;
|
2019-03-22 15:39:01 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
DROP TABLE defaults;
|