mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-17 03:42:48 +00:00
767 lines
29 KiB
Plaintext
767 lines
29 KiB
Plaintext
-- { echoOn }
|
|
|
|
SELECT 'Constants';
|
|
Constants
|
|
DESCRIBE (SELECT 1, 'Value');
|
|
1 UInt8
|
|
\'Value\' String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT 1 + 1, concat('Value_1', 'Value_2'));
|
|
plus(1, 1) UInt16
|
|
concat(\'Value_1\', \'Value_2\') String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT cast(tuple(1, 'Value'), 'Tuple (id UInt64, value String)'));
|
|
CAST((1, \'Value\'), \'Tuple (id UInt64, value String)\') Tuple(\n id UInt64,\n value String)
|
|
SELECT 'Columns';
|
|
Columns
|
|
DESCRIBE (SELECT test_table.id, test_table.id, id FROM test_table);
|
|
id UInt64
|
|
id UInt64
|
|
id UInt64
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT * FROM test_table);
|
|
id UInt64
|
|
value String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT * APPLY toString FROM test_table);
|
|
toString(id) String
|
|
toString(value) String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT * APPLY x -> toString(x) FROM test_table);
|
|
toString(id) String
|
|
toString(value) String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT tuple_value.* FROM test_table_compound);
|
|
tuple_value.value_1 UInt64
|
|
tuple_value.value_2 String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT tuple_value.* APPLY x -> x FROM test_table_compound);
|
|
tuple_value.value_1 UInt64
|
|
tuple_value.value_2 String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT tuple_value.* APPLY toString FROM test_table_compound);
|
|
toString(tuple_value.value_1) String
|
|
toString(tuple_value.value_2) String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT tuple_value.* APPLY x -> toString(x) FROM test_table_compound);
|
|
toString(tuple_value.value_1) String
|
|
toString(tuple_value.value_2) String
|
|
SELECT 'Constants with aliases';
|
|
Constants with aliases
|
|
DESCRIBE (SELECT 1 AS a, a AS b, b, b AS c, c, 'Value' AS d, d AS e, e AS f);
|
|
a UInt8
|
|
b UInt8
|
|
b UInt8
|
|
c UInt8
|
|
c UInt8
|
|
d String
|
|
e String
|
|
f String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT plus(1 AS a, a AS b), plus(b, b), plus(b, b) AS c, concat('Value' AS d, d) AS e, e);
|
|
plus(a, b) UInt16
|
|
plus(b, b) UInt16
|
|
c UInt16
|
|
e String
|
|
e String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT cast(tuple(1, 'Value'), 'Tuple (id UInt64, value String)') AS a, a.id, a.value);
|
|
a Tuple(\n id UInt64,\n value String)
|
|
a.id UInt64
|
|
a.value String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT cast(tuple(1, 'Value'), 'Tuple (id UInt64, value String)') AS a, a.*);
|
|
a Tuple(\n id UInt64,\n value String)
|
|
a.id UInt64
|
|
a.value String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT cast(tuple(1, 'Value'), 'Tuple (id UInt64, value String)') AS a, a.* EXCEPT id);
|
|
a Tuple(\n id UInt64,\n value String)
|
|
a.value String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT cast(tuple(1, 'Value'), 'Tuple (id UInt64, value String)') AS a, a.* EXCEPT value);
|
|
a Tuple(\n id UInt64,\n value String)
|
|
a.id UInt64
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT cast(tuple(1, 'Value'), 'Tuple (id UInt64, value String)') AS a, a.* EXCEPT value APPLY toString);
|
|
a Tuple(\n id UInt64,\n value String)
|
|
toString(a.id) String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT cast(tuple(1, 'Value'), 'Tuple (id UInt64, value String)') AS a, a.* EXCEPT value APPLY x -> toString(x));
|
|
a Tuple(\n id UInt64,\n value String)
|
|
toString(a.id) String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT cast(tuple(1, 'Value'), 'Tuple (id UInt64, value String)') AS a, untuple(a));
|
|
a Tuple(\n id UInt64,\n value String)
|
|
tupleElement(a, \'id\') UInt64
|
|
tupleElement(a, \'value\') String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT cast(tuple(1, 'Value'), 'Tuple (id UInt64, value String)') AS a, untuple(a) AS b);
|
|
a Tuple(\n id UInt64,\n value String)
|
|
b.id UInt64
|
|
b.value String
|
|
SELECT 'Columns with aliases';
|
|
Columns with aliases
|
|
DESCRIBE (SELECT test_table.id AS a, a, test_table.id AS b, b AS c, c FROM test_table);
|
|
a UInt64
|
|
a UInt64
|
|
b UInt64
|
|
c UInt64
|
|
c UInt64
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT plus(test_table.id AS a, test_table.id), plus(id, id AS b), plus(b, b), plus(test_table.id, test_table.id) FROM test_table);
|
|
plus(a, id) UInt64
|
|
plus(id, b) UInt64
|
|
plus(b, b) UInt64
|
|
plus(id, id) UInt64
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT test_table.* REPLACE id + (id AS id_alias) AS id, id_alias FROM test_table);
|
|
id UInt64
|
|
value String
|
|
id_alias UInt64
|
|
SELECT 'Matcher';
|
|
Matcher
|
|
DESCRIBE (SELECT * FROM test_table);
|
|
id UInt64
|
|
value String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT test_table.* FROM test_table);
|
|
id UInt64
|
|
value String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT 1 AS id, 2 AS value, * FROM test_table);
|
|
id UInt8
|
|
value UInt8
|
|
test_table.id UInt64
|
|
test_table.value String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT 1 AS id, 2 AS value, * FROM test_table AS t1);
|
|
id UInt8
|
|
value UInt8
|
|
t1.id UInt64
|
|
t1.value String
|
|
SELECT 'Lambda';
|
|
Lambda
|
|
DESCRIBE (SELECT arrayMap(x -> x + 1, [1,2,3]));
|
|
arrayMap(lambda(tuple(x), plus(x, 1)), [1, 2, 3]) Array(UInt16)
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT 1 AS a, arrayMap(x -> x + a, [1,2,3]));
|
|
a UInt8
|
|
arrayMap(lambda(tuple(x), plus(x, a)), [1, 2, 3]) Array(UInt16)
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT arrayMap(x -> x + test_table.id + test_table.id + id, [1,2,3]) FROM test_table);
|
|
arrayMap(lambda(tuple(x), plus(plus(plus(x, id), id), id)), [1, 2, 3]) Array(UInt64)
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT arrayMap(x -> x + (test_table.id AS first) + (test_table.id AS second) + id, [1,2,3]) FROM test_table);
|
|
arrayMap(lambda(tuple(x), plus(plus(plus(x, first), second), id)), [1, 2, 3]) Array(UInt64)
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT arrayMap(x -> test_table.* EXCEPT value, [1,2,3]) FROM test_table);
|
|
arrayMap(lambda(tuple(x), id), [1, 2, 3]) Array(UInt64)
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT arrayMap(x -> test_table.* EXCEPT value APPLY x -> x, [1,2,3]) FROM test_table);
|
|
arrayMap(lambda(tuple(x), id), [1, 2, 3]) Array(UInt64)
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT arrayMap(x -> test_table.* EXCEPT value APPLY toString, [1,2,3]) FROM test_table);
|
|
arrayMap(lambda(tuple(x), toString(id)), [1, 2, 3]) Array(String)
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT arrayMap(x -> test_table.* EXCEPT value APPLY x -> toString(x), [1,2,3]) FROM test_table);
|
|
arrayMap(lambda(tuple(x), toString(id)), [1, 2, 3]) Array(String)
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT cast(tuple(1), 'Tuple (id UInt64)') AS compound_value, arrayMap(x -> compound_value.*, [1,2,3]));
|
|
compound_value Tuple(\n id UInt64)
|
|
arrayMap(lambda(tuple(x), compound_value.id), [1, 2, 3]) Array(UInt64)
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT cast(tuple(1), 'Tuple (id UInt64)') AS compound_value, arrayMap(x -> compound_value.* APPLY x -> x, [1,2,3]));
|
|
compound_value Tuple(\n id UInt64)
|
|
arrayMap(lambda(tuple(x), compound_value.id), [1, 2, 3]) Array(UInt64)
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT cast(tuple(1), 'Tuple (id UInt64)') AS compound_value, arrayMap(x -> compound_value.* APPLY toString, [1,2,3]));
|
|
compound_value Tuple(\n id UInt64)
|
|
arrayMap(lambda(tuple(x), toString(compound_value.id)), [1, 2, 3]) Array(String)
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT cast(tuple(1), 'Tuple (id UInt64)') AS compound_value, arrayMap(x -> compound_value.* APPLY x -> toString(x), [1,2,3]));
|
|
compound_value Tuple(\n id UInt64)
|
|
arrayMap(lambda(tuple(x), toString(compound_value.id)), [1, 2, 3]) Array(String)
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT cast(tuple(1, 'Value'), 'Tuple (id UInt64, value String)') AS compound_value, arrayMap(x -> compound_value.* EXCEPT value, [1,2,3]));
|
|
compound_value Tuple(\n id UInt64,\n value String)
|
|
arrayMap(lambda(tuple(x), compound_value.id), [1, 2, 3]) Array(UInt64)
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT cast(tuple(1, 'Value'), 'Tuple (id UInt64, value String)') AS compound_value, arrayMap(x -> compound_value.* EXCEPT value APPLY x -> x, [1,2,3]));
|
|
compound_value Tuple(\n id UInt64,\n value String)
|
|
arrayMap(lambda(tuple(x), compound_value.id), [1, 2, 3]) Array(UInt64)
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT cast(tuple(1, 'Value'), 'Tuple (id UInt64, value String)') AS compound_value, arrayMap(x -> compound_value.* EXCEPT value APPLY toString, [1,2,3]));
|
|
compound_value Tuple(\n id UInt64,\n value String)
|
|
arrayMap(lambda(tuple(x), toString(compound_value.id)), [1, 2, 3]) Array(String)
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT cast(tuple(1, 'Value'), 'Tuple (id UInt64, value String)') AS compound_value, arrayMap(x -> compound_value.* EXCEPT value APPLY x -> toString(x), [1,2,3]));
|
|
compound_value Tuple(\n id UInt64,\n value String)
|
|
arrayMap(lambda(tuple(x), toString(compound_value.id)), [1, 2, 3]) Array(String)
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT cast(tuple(1), 'Tuple (id UInt64)') AS a, arrayMap(x -> untuple(a), [1,2,3]) FROM test_table);
|
|
a Tuple(\n id UInt64)
|
|
arrayMap(lambda(tuple(x), tupleElement(a, \'id\')), [1, 2, 3]) Array(UInt64)
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT cast(tuple(1), 'Tuple (id UInt64)') AS a, arrayMap(x -> untuple(a) AS untupled_value, [1,2,3]) FROM test_table);
|
|
a Tuple(\n id UInt64)
|
|
arrayMap(untupled_value, [1, 2, 3]) Array(UInt64)
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT cast(tuple(1), 'Tuple (id UInt64)') AS a, untuple(a) AS untupled_value, arrayMap(x -> untupled_value, [1,2,3]) FROM test_table);
|
|
a Tuple(\n id UInt64)
|
|
untupled_value.id UInt64
|
|
arrayMap(lambda(tuple(x), untupled_value.id), [1, 2, 3]) Array(UInt64)
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT cast(tuple(1), 'Tuple (id UInt64)') AS a, untuple(a) AS untupled_value, arrayMap(x -> untupled_value AS untupled_value_in_lambda, [1,2,3]) FROM test_table);
|
|
a Tuple(\n id UInt64)
|
|
untupled_value.id UInt64
|
|
arrayMap(untupled_value_in_lambda, [1, 2, 3]) Array(UInt64)
|
|
SELECT 'Standalone lambda';
|
|
Standalone lambda
|
|
DESCRIBE (WITH x -> x + 1 AS test_lambda SELECT test_lambda(1));
|
|
test_lambda(1) UInt16
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (WITH x -> * AS test_lambda SELECT test_lambda(1) AS lambda_value, lambda_value FROM test_table);
|
|
id UInt64
|
|
value String
|
|
id UInt64
|
|
value String
|
|
SELECT 'Subquery';
|
|
Subquery
|
|
DESCRIBE (SELECT (SELECT 1), (SELECT 2), (SELECT 3) AS a, (SELECT 4));
|
|
_subquery_1 Nullable(UInt8)
|
|
_subquery_2 Nullable(UInt8)
|
|
a Nullable(UInt8)
|
|
_subquery_4 Nullable(UInt8)
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT arrayMap(x -> (SELECT 1), [1,2,3]), arrayMap(x -> (SELECT 2) AS a, [1, 2, 3]), arrayMap(x -> (SELECT 1), [1,2,3]));
|
|
arrayMap(lambda(tuple(x), _subquery_1), [1, 2, 3]) Array(Nullable(UInt8))
|
|
arrayMap(a, [1, 2, 3]) Array(Nullable(UInt8))
|
|
arrayMap(lambda(tuple(x), _subquery_3), [1, 2, 3]) Array(Nullable(UInt8))
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT (SELECT 1 AS a, 2 AS b) AS c, c.a, c.b);
|
|
c Tuple(\n a UInt8,\n b UInt8)
|
|
c.a UInt8
|
|
c.b UInt8
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT (SELECT 1 AS a, 2 AS b) AS c, c.*);
|
|
c Tuple(\n a UInt8,\n b UInt8)
|
|
c.a UInt8
|
|
c.b UInt8
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT (SELECT 1 UNION DISTINCT SELECT 1), (SELECT 2 UNION DISTINCT SELECT 2), (SELECT 3 UNION DISTINCT SELECT 3) AS a, (SELECT 4 UNION DISTINCT SELECT 4));
|
|
_subquery_1 Nullable(UInt8)
|
|
_subquery_2 Nullable(UInt8)
|
|
a Nullable(UInt8)
|
|
_subquery_4 Nullable(UInt8)
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT arrayMap(x -> (SELECT 1 UNION DISTINCT SELECT 1), [1,2,3]), arrayMap(x -> (SELECT 2 UNION DISTINCT SELECT 2) AS a, [1, 2, 3]),
|
|
arrayMap(x -> (SELECT 3 UNION DISTINCT SELECT 3), [1,2,3]));
|
|
arrayMap(lambda(tuple(x), _subquery_1), [1, 2, 3]) Array(Nullable(UInt8))
|
|
arrayMap(a, [1, 2, 3]) Array(Nullable(UInt8))
|
|
arrayMap(lambda(tuple(x), _subquery_3), [1, 2, 3]) Array(Nullable(UInt8))
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT (SELECT 1 AS a, 2 AS b UNION DISTINCT SELECT 1, 2) AS c, c.a, c.b);
|
|
c Tuple(\n a UInt8,\n b UInt8)
|
|
c.a UInt8
|
|
c.b UInt8
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT (SELECT 1 AS a, 2 AS b UNION DISTINCT SELECT 1, 2) AS c, c.*);
|
|
c Tuple(\n a UInt8,\n b UInt8)
|
|
c.a UInt8
|
|
c.b UInt8
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT (SELECT 1), (SELECT 2 UNION DISTINCT SELECT 2), (SELECT 3) AS a, (SELECT 4 UNION DISTINCT SELECT 4));
|
|
_subquery_1 Nullable(UInt8)
|
|
_subquery_2 Nullable(UInt8)
|
|
a Nullable(UInt8)
|
|
_subquery_4 Nullable(UInt8)
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT arrayMap(x -> (SELECT 1 UNION DISTINCT SELECT 1), [1,2,3]), arrayMap(x -> (SELECT 2) AS a, [1, 2, 3]),
|
|
arrayMap(x -> (SELECT 3 UNION DISTINCT SELECT 3), [1,2,3]));
|
|
arrayMap(lambda(tuple(x), _subquery_1), [1, 2, 3]) Array(Nullable(UInt8))
|
|
arrayMap(a, [1, 2, 3]) Array(Nullable(UInt8))
|
|
arrayMap(lambda(tuple(x), _subquery_3), [1, 2, 3]) Array(Nullable(UInt8))
|
|
SELECT 'Window functions';
|
|
Window functions
|
|
DESCRIBE (SELECT count() OVER ());
|
|
count() OVER () UInt64
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT count() OVER () AS window_function);
|
|
window_function UInt64
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT count() OVER (PARTITION BY id) FROM test_table);
|
|
count() OVER (PARTITION BY id) UInt64
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT count() OVER (PARTITION BY id, value) FROM test_table);
|
|
count() OVER (PARTITION BY id, value) UInt64
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT count() OVER (PARTITION BY id, value ORDER BY id) FROM test_table);
|
|
count() OVER (PARTITION BY id, value ORDER BY id ASC) UInt64
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT count() OVER (PARTITION BY id, value ORDER BY id ASC, value DESC ROWS CURRENT ROW) FROM test_table);
|
|
count() OVER (PARTITION BY id, value ORDER BY id ASC, value DESC ROWS BETWEEN CURRENT ROW AND CURRENT ROW) UInt64
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT count() OVER (PARTITION BY id, value ORDER BY id ASC, value DESC ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM test_table);
|
|
count() OVER (PARTITION BY id, value ORDER BY id ASC, value DESC ROWS BETWEEN CURRENT ROW AND CURRENT ROW) UInt64
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT count() OVER (PARTITION BY id, value ORDER BY id ASC, value DESC RANGE CURRENT ROW) FROM test_table);
|
|
count() OVER (PARTITION BY id, value ORDER BY id ASC, value DESC RANGE BETWEEN CURRENT ROW AND CURRENT ROW) UInt64
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT count() OVER (PARTITION BY id, value ORDER BY id ASC, value DESC RANGE BETWEEN CURRENT ROW AND CURRENT ROW) FROM test_table);
|
|
count() OVER (PARTITION BY id, value ORDER BY id ASC, value DESC RANGE BETWEEN CURRENT ROW AND CURRENT ROW) UInt64
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT count() OVER (PARTITION BY (id AS id_alias), (value AS value_alias) ORDER BY id ASC, value DESC ROWS CURRENT ROW) FROM test_table);
|
|
count() OVER (PARTITION BY id_alias, value_alias ORDER BY id ASC, value DESC ROWS BETWEEN CURRENT ROW AND CURRENT ROW) UInt64
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT count() OVER (PARTITION BY id, value ORDER BY (id AS id_alias) ASC, (value AS value_alias) DESC ROWS CURRENT ROW) FROM test_table);
|
|
count() OVER (PARTITION BY id, value ORDER BY id_alias ASC, value_alias DESC ROWS BETWEEN CURRENT ROW AND CURRENT ROW) UInt64
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT count() OVER (PARTITION BY id, value ORDER BY id ASC, value DESC ROWS BETWEEN 1 PRECEDING AND 2 FOLLOWING) FROM test_table);
|
|
count() OVER (PARTITION BY id, value ORDER BY id ASC, value DESC ROWS BETWEEN 1 PRECEDING AND 2 FOLLOWING) UInt64
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT count() OVER (PARTITION BY id, value ORDER BY id ASC, value DESC ROWS BETWEEN 1 + 1 PRECEDING AND 2 + 2 FOLLOWING) FROM test_table);
|
|
count() OVER (PARTITION BY id, value ORDER BY id ASC, value DESC ROWS BETWEEN plus(1, 1) PRECEDING AND plus(2, 2) FOLLOWING) UInt64
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT count() OVER (PARTITION BY id, value ORDER BY id ASC, value DESC ROWS BETWEEN ((1 + 1) AS frame_offset_begin) PRECEDING AND ((2 + 2) AS frame_offset_end) FOLLOWING)
|
|
FROM test_table);
|
|
count() OVER (PARTITION BY id, value ORDER BY id ASC, value DESC ROWS BETWEEN frame_offset_begin PRECEDING AND frame_offset_end FOLLOWING) UInt64
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT count() OVER (ORDER BY toNullable(id) NULLS FIRST) FROM test_table);
|
|
count() OVER (ORDER BY toNullable(id) ASC NULLS FIRST) UInt64
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT count() OVER (ORDER BY toNullable(id) NULLS LAST) FROM test_table);
|
|
count() OVER (ORDER BY toNullable(id) ASC NULLS LAST) UInt64
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT count() OVER (ORDER BY id WITH FILL FROM 1 TO 5 STEP 1) FROM test_table);
|
|
count() OVER (ORDER BY id ASC WITH FILL FROM 1 TO 5 STEP 1) UInt64
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT count() OVER (ORDER BY id WITH FILL FROM 1 + 1 TO 6 STEP 1 + 1) FROM test_table);
|
|
count() OVER (ORDER BY id ASC WITH FILL FROM plus(1, 1) TO 6 STEP plus(1, 1)) UInt64
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT count() OVER (ORDER BY id WITH FILL FROM ((1 + 1) AS from) TO (6 AS to) STEP ((1 + 1) AS step)) FROM test_table);
|
|
count() OVER (ORDER BY id ASC WITH FILL FROM from TO to STEP step) UInt64
|
|
SELECT 'Window functions WINDOW';
|
|
Window functions WINDOW
|
|
DESCRIBE (SELECT count() OVER window_name FROM test_table WINDOW window_name AS (PARTITION BY id));
|
|
count() OVER window_name UInt64
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT count() OVER window_name FROM test_table WINDOW window_name AS (PARTITION BY id ORDER BY value));
|
|
count() OVER window_name UInt64
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT count() OVER (window_name ORDER BY id) FROM test_table WINDOW window_name AS (PARTITION BY id));
|
|
count() OVER (window_name ORDER BY id ASC) UInt64
|
|
SELECT 'IN function';
|
|
IN function
|
|
DESCRIBE (SELECT id IN (SELECT 1) FROM test_table);
|
|
in(id, _subquery_1) UInt8
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT id IN (SELECT id FROM test_table_in) FROM test_table);
|
|
in(id, _subquery_1) UInt8
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT id IN test_table_in FROM test_table);
|
|
in(id, test_table_in) UInt8
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (WITH test_table_in_cte AS (SELECT id FROM test_table) SELECT id IN (SELECT id FROM test_table_in_cte) FROM test_table);
|
|
in(id, _subquery_1) UInt8
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (WITH test_table_in_cte AS (SELECT id FROM test_table) SELECT id IN test_table_in_cte FROM test_table);
|
|
in(id, test_table_in_cte) UInt8
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (WITH test_table_in_cte_1 AS (SELECT 1 AS c1), test_table_in_cte_2 AS (SELECT 1 AS c1) SELECT *
|
|
FROM test_table_in_cte_1 INNER JOIN test_table_in_cte_2 as test_table_in_cte_2 ON test_table_in_cte_1.c1 = test_table_in_cte_2.c1);
|
|
test_table_in_cte_1.c1 UInt8
|
|
test_table_in_cte_2.c1 UInt8
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (WITH test_table_in_cte_1 AS (SELECT 1 AS c1), test_table_in_cte_2 AS (SELECT 1 AS c1 UNION ALL SELECT 1 AS c1) SELECT *
|
|
FROM test_table_in_cte_1 INNER JOIN test_table_in_cte_2 as test_table_in_cte_2 ON test_table_in_cte_1.c1 = test_table_in_cte_2.c1);
|
|
test_table_in_cte_1.c1 UInt8
|
|
test_table_in_cte_2.c1 UInt8
|
|
SELECT 'Joins';
|
|
Joins
|
|
DESCRIBE (SELECT * FROM test_table_join_1, test_table_join_2);
|
|
test_table_join_1.id UInt64
|
|
test_table_join_1.value String
|
|
value_join_1 String
|
|
test_table_join_2.id UInt64
|
|
test_table_join_2.value String
|
|
value_join_2 String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT * FROM test_table_join_1 AS t1, test_table_join_2 AS t2);
|
|
t1.id UInt64
|
|
t1.value String
|
|
value_join_1 String
|
|
t2.id UInt64
|
|
t2.value String
|
|
value_join_2 String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT * APPLY toString FROM test_table_join_1 AS t1, test_table_join_2 AS t2);
|
|
toString(t1.id) String
|
|
toString(t1.value) String
|
|
toString(value_join_1) String
|
|
toString(t2.id) String
|
|
toString(t2.value) String
|
|
toString(value_join_2) String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT * APPLY x -> toString(x) FROM test_table_join_1 AS t1, test_table_join_2 AS t2);
|
|
toString(t1.id) String
|
|
toString(t1.value) String
|
|
toString(value_join_1) String
|
|
toString(t2.id) String
|
|
toString(t2.value) String
|
|
toString(value_join_2) String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT test_table_join_1.*, test_table_join_2.* FROM test_table_join_1 INNER JOIN test_table_join_2 ON test_table_join_1.id = test_table_join_2.id);
|
|
test_table_join_1.id UInt64
|
|
test_table_join_1.value String
|
|
value_join_1 String
|
|
test_table_join_2.id UInt64
|
|
test_table_join_2.value String
|
|
value_join_2 String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT t1.*, t2.* FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id);
|
|
t1.id UInt64
|
|
t1.value String
|
|
value_join_1 String
|
|
t2.id UInt64
|
|
t2.value String
|
|
value_join_2 String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT test_table_join_1.* APPLY toString, test_table_join_2.* APPLY toString FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id);
|
|
toString(t1.id) String
|
|
toString(t1.value) String
|
|
toString(value_join_1) String
|
|
toString(t2.id) String
|
|
toString(t2.value) String
|
|
toString(value_join_2) String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT test_table_join_1.* APPLY x -> toString(x), test_table_join_2.* APPLY x -> toString(x) FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id);
|
|
toString(t1.id) String
|
|
toString(t1.value) String
|
|
toString(value_join_1) String
|
|
toString(t2.id) String
|
|
toString(t2.value) String
|
|
toString(value_join_2) String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT test_table_join_1.id, test_table_join_1.value, test_table_join_1.value_join_1, test_table_join_2.id, test_table_join_2.value, test_table_join_2.value_join_2
|
|
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id);
|
|
test_table_join_1.id UInt64
|
|
test_table_join_1.value String
|
|
value_join_1 String
|
|
test_table_join_2.id UInt64
|
|
test_table_join_2.value String
|
|
value_join_2 String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT t1.id, t1.value, t1.value_join_1, t2.id, t2.value, t2.value_join_2 FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id);
|
|
t1.id UInt64
|
|
t1.value String
|
|
value_join_1 String
|
|
t2.id UInt64
|
|
t2.value String
|
|
value_join_2 String
|
|
SELECT 'Multiple JOINS';
|
|
Multiple JOINS
|
|
DESCRIBE (SELECT * FROM test_table_join_1, test_table_join_2, test_table_join_3);
|
|
test_table_join_1.id UInt64
|
|
test_table_join_1.value String
|
|
value_join_1 String
|
|
test_table_join_2.id UInt64
|
|
test_table_join_2.value String
|
|
value_join_2 String
|
|
test_table_join_3.id UInt64
|
|
test_table_join_3.value String
|
|
value_join_3 String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT * FROM test_table_join_1 AS t1, test_table_join_2 AS t2, test_table_join_3 AS t3);
|
|
t1.id UInt64
|
|
t1.value String
|
|
value_join_1 String
|
|
t2.id UInt64
|
|
t2.value String
|
|
value_join_2 String
|
|
t3.id UInt64
|
|
t3.value String
|
|
value_join_3 String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT * APPLY toString FROM test_table_join_1 AS t1, test_table_join_2 AS t2, test_table_join_3 AS t3);
|
|
toString(t1.id) String
|
|
toString(t1.value) String
|
|
toString(value_join_1) String
|
|
toString(t2.id) String
|
|
toString(t2.value) String
|
|
toString(value_join_2) String
|
|
toString(t3.id) String
|
|
toString(t3.value) String
|
|
toString(value_join_3) String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT * APPLY x -> toString(x) FROM test_table_join_1 AS t1, test_table_join_2 AS t2, test_table_join_3 AS t3);
|
|
toString(t1.id) String
|
|
toString(t1.value) String
|
|
toString(value_join_1) String
|
|
toString(t2.id) String
|
|
toString(t2.value) String
|
|
toString(value_join_2) String
|
|
toString(t3.id) String
|
|
toString(t3.value) String
|
|
toString(value_join_3) String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT test_table_join_1.*, test_table_join_2.*, test_table_join_3.*
|
|
FROM test_table_join_1 INNER JOIN test_table_join_2 ON test_table_join_1.id = test_table_join_2.id
|
|
INNER JOIN test_table_join_3 ON test_table_join_2.id = test_table_join_3.id);
|
|
test_table_join_1.id UInt64
|
|
test_table_join_1.value String
|
|
value_join_1 String
|
|
test_table_join_2.id UInt64
|
|
test_table_join_2.value String
|
|
value_join_2 String
|
|
test_table_join_3.id UInt64
|
|
test_table_join_3.value String
|
|
value_join_3 String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT t1.*, t2.*, t3.*
|
|
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id INNER JOIN test_table_join_3 AS t3 ON t2.id = t3.id);
|
|
t1.id UInt64
|
|
t1.value String
|
|
value_join_1 String
|
|
t2.id UInt64
|
|
t2.value String
|
|
value_join_2 String
|
|
t3.id UInt64
|
|
t3.value String
|
|
value_join_3 String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT test_table_join_1.* APPLY toString, test_table_join_2.* APPLY toString, test_table_join_3.* APPLY toString
|
|
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id INNER JOIN test_table_join_3 AS t3 ON t2.id = t3.id);
|
|
toString(t1.id) String
|
|
toString(t1.value) String
|
|
toString(value_join_1) String
|
|
toString(t2.id) String
|
|
toString(t2.value) String
|
|
toString(value_join_2) String
|
|
toString(t3.id) String
|
|
toString(t3.value) String
|
|
toString(value_join_3) String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT test_table_join_1.* APPLY x -> toString(x), test_table_join_2.* APPLY x -> toString(x), test_table_join_3.* APPLY x -> toString(x)
|
|
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id INNER JOIN test_table_join_3 AS t3 ON t2.id = t3.id);
|
|
toString(t1.id) String
|
|
toString(t1.value) String
|
|
toString(value_join_1) String
|
|
toString(t2.id) String
|
|
toString(t2.value) String
|
|
toString(value_join_2) String
|
|
toString(t3.id) String
|
|
toString(t3.value) String
|
|
toString(value_join_3) String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT test_table_join_1.id, test_table_join_1.value, test_table_join_1.value_join_1, test_table_join_2.id, test_table_join_2.value, test_table_join_2.value_join_2,
|
|
test_table_join_3.id, test_table_join_3.value, test_table_join_3.value_join_3
|
|
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id INNER JOIN test_table_join_3 AS t3 ON t2.id = t3.id);
|
|
test_table_join_1.id UInt64
|
|
test_table_join_1.value String
|
|
value_join_1 String
|
|
test_table_join_2.id UInt64
|
|
test_table_join_2.value String
|
|
value_join_2 String
|
|
test_table_join_3.id UInt64
|
|
test_table_join_3.value String
|
|
value_join_3 String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT t1.id, t1.value, t1.value_join_1, t2.id, t2.value, t2.value_join_2, t3.id, t3.value, t3.value_join_3
|
|
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id INNER JOIN test_table_join_3 AS t3 ON t2.id = t3.id);
|
|
t1.id UInt64
|
|
t1.value String
|
|
value_join_1 String
|
|
t2.id UInt64
|
|
t2.value String
|
|
value_join_2 String
|
|
t3.id UInt64
|
|
t3.value String
|
|
value_join_3 String
|
|
SELECT 'Joins USING';
|
|
Joins USING
|
|
DESCRIBE (SELECT * FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 USING (id));
|
|
id UInt64
|
|
t1.value String
|
|
value_join_1 String
|
|
t2.value String
|
|
value_join_2 String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT * FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 USING (id, value));
|
|
id UInt64
|
|
value String
|
|
value_join_1 String
|
|
value_join_2 String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT id, t1.id, t1.value, t2.id, t2.value FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 USING (id));
|
|
id UInt64
|
|
t1.id UInt64
|
|
t1.value String
|
|
t2.id UInt64
|
|
t2.value String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT id, value, t1.id, t1.value, t2.id, t2.value FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 USING (id, value));
|
|
id UInt64
|
|
value String
|
|
t1.id UInt64
|
|
t1.value String
|
|
t2.id UInt64
|
|
t2.value String
|
|
SELECT 'Multiple Joins USING';
|
|
Multiple Joins USING
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT * FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 USING (id) INNER JOIN test_table_join_3 AS t3 USING (id));
|
|
id UInt64
|
|
t1.value String
|
|
value_join_1 String
|
|
t2.value String
|
|
value_join_2 String
|
|
t3.value String
|
|
value_join_3 String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT * FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 USING (id, value) INNER JOIN test_table_join_3 AS t3 USING (id, value));
|
|
id UInt64
|
|
value String
|
|
value_join_1 String
|
|
value_join_2 String
|
|
value_join_3 String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT id, t1.id, t1.value, t2.id, t2.value, t3.id, t3.value
|
|
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 USING (id) INNER JOIN test_table_join_3 AS t3 USING (id));
|
|
id UInt64
|
|
t1.id UInt64
|
|
t1.value String
|
|
t2.id UInt64
|
|
t2.value String
|
|
t3.id UInt64
|
|
t3.value String
|
|
SELECT '--';
|
|
--
|
|
DESCRIBE (SELECT id, value, t1.id, t1.value, t2.id, t2.value, t3.id, t3.value
|
|
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 USING (id, value) INNER JOIN test_table_join_3 AS t3 USING (id, value));
|
|
id UInt64
|
|
value String
|
|
t1.id UInt64
|
|
t1.value String
|
|
t2.id UInt64
|
|
t2.value String
|
|
t3.id UInt64
|
|
t3.value String
|
|
SELECT 'Special functions array, tuple';
|
|
Special functions array, tuple
|
|
DESCRIBE (SELECT [], array(), [1], array(1), [1, 2], array(1, 2), tuple(1), (1, 2), [[], []], [([], [])], ([], []), ([([], []), ([], [])]));
|
|
[] Array(Nothing)
|
|
[] Array(Nothing)
|
|
[1] Array(UInt8)
|
|
[1] Array(UInt8)
|
|
[1, 2] Array(UInt8)
|
|
[1, 2] Array(UInt8)
|
|
(1) Tuple(UInt8)
|
|
(1, 2) Tuple(UInt8, UInt8)
|
|
[[], []] Array(Array(Nothing))
|
|
[([], [])] Array(Tuple(Array(Nothing), Array(Nothing)))
|
|
([], []) Tuple(Array(Nothing), Array(Nothing))
|
|
[([], []), ([], [])] Array(Tuple(Array(Nothing), Array(Nothing)))
|