ClickHouse/tests/queries/0_stateless/02389_analyzer_nested_lambda.reference
2022-10-24 16:14:05 +02:00

122 lines
4.1 KiB
Plaintext

-- { echoOn }
SELECT arrayMap(x -> x + arrayMap(x -> x + 1, [1])[1], [1,2,3]);
[3,4,5]
SELECT '--';
--
SELECT arrayMap(x -> x + arrayMap(x -> 5, [1])[1], [1,2,3]);
[6,7,8]
SELECT '--';
--
SELECT 5 AS constant, arrayMap(x -> x + arrayMap(x -> constant, [1])[1], [1,2,3]);
5 [6,7,8]
SELECT '--';
--
SELECT arrayMap(x -> x + arrayMap(x -> x, [1])[1], [1,2,3]);
[2,3,4]
SELECT '--';
--
SELECT arrayMap(x -> x + arrayMap(y -> x + y, [1])[1], [1,2,3]);
[3,5,7]
SELECT '--';
--
SELECT arrayMap(x -> x + arrayMap(x -> (SELECT 5), [1])[1], [1,2,3]);
[6,7,8]
SELECT '--';
--
SELECT (SELECT 5) AS subquery, arrayMap(x -> x + arrayMap(x -> subquery, [1])[1], [1,2,3]);
5 [6,7,8]
SELECT '--';
--
SELECT arrayMap(x -> x + arrayMap(x -> (SELECT 5 UNION DISTINCT SELECT 5), [1])[1], [1,2,3]);
[6,7,8]
SELECT '--';
--
SELECT (SELECT 5 UNION DISTINCT SELECT 5) AS subquery, arrayMap(x -> x + arrayMap(x -> subquery, [1])[1], [1,2,3]);
5 [6,7,8]
SELECT '--';
--
WITH x -> toString(x) AS lambda SELECT arrayMap(x -> lambda(x), [1,2,3]);
['1','2','3']
SELECT '--';
--
WITH x -> toString(x) AS lambda SELECT arrayMap(x -> arrayMap(y -> concat(lambda(x), '_', lambda(y)), [1,2,3]), [1,2,3]);
[['1_1','1_2','1_3'],['2_1','2_2','2_3'],['3_1','3_2','3_3']]
SELECT '--';
--
DROP TABLE IF EXISTS test_table;
CREATE TABLE test_table
(
id UInt64,
value String
) ENGINE=TinyLog;
INSERT INTO test_table VALUES (0, 'Value');
SELECT arrayMap(x -> x + arrayMap(x -> id, [1])[1], [1,2,3]) FROM test_table;
[1,2,3]
SELECT '--';
--
SELECT arrayMap(x -> x + arrayMap(x -> x + id, [1])[1], [1,2,3]) FROM test_table;
[2,3,4]
SELECT '--';
--
SELECT arrayMap(x -> x + arrayMap(y -> x + y + id, [1])[1], [1,2,3]) FROM test_table;
[3,5,7]
SELECT '--';
--
SELECT id AS id_alias, arrayMap(x -> x + arrayMap(y -> x + y + id_alias, [1])[1], [1,2,3]) FROM test_table;
0 [3,5,7]
SELECT '--';
--
SELECT arrayMap(x -> x + arrayMap(x -> 5, [1])[1], [1,2,3]) FROM test_table;
[6,7,8]
SELECT '--';
--
SELECT 5 AS constant, arrayMap(x -> x + arrayMap(x -> constant, [1])[1], [1,2,3]) FROM test_table;
5 [6,7,8]
SELECT '--';
--
SELECT 5 AS constant, arrayMap(x -> x + arrayMap(x -> x + constant, [1])[1], [1,2,3]) FROM test_table;
5 [7,8,9]
SELECT '--';
--
SELECT 5 AS constant, arrayMap(x -> x + arrayMap(x -> x + id + constant, [1])[1], [1,2,3]) FROM test_table;
5 [7,8,9]
SELECT '--';
--
SELECT 5 AS constant, arrayMap(x -> x + arrayMap(y -> x + y + id + constant, [1])[1], [1,2,3]) FROM test_table;
5 [8,10,12]
SELECT '--';
--
SELECT arrayMap(x -> x + arrayMap(x -> id + (SELECT id FROM test_table), [1])[1], [1,2,3]) FROM test_table;
[1,2,3]
SELECT '--';
--
SELECT arrayMap(x -> id + arrayMap(x -> id + (SELECT id FROM test_table), [1])[1], [1,2,3]) FROM test_table;
[0,0,0]
SELECT '--';
--
SELECT arrayMap(x -> id + arrayMap(x -> id + (SELECT id FROM test_table UNION DISTINCT SELECT id FROM test_table), [1])[1], [1,2,3]) FROM test_table;
[0,0,0]
SELECT '--';
--
WITH x -> toString(id) AS lambda SELECT arrayMap(x -> lambda(x), [1,2,3]) FROM test_table;
['0','0','0']
SELECT '--';
--
WITH x -> toString(id) AS lambda SELECT arrayMap(x -> arrayMap(y -> lambda(y), [1,2,3]), [1,2,3]) FROM test_table;
[['0','0','0'],['0','0','0'],['0','0','0']]
SELECT '--';
--
WITH x -> toString(id) AS lambda SELECT arrayMap(x -> arrayMap(y -> concat(lambda(x), '_', lambda(y)), [1,2,3]), [1,2,3]) FROM test_table;
[['0_0','0_0','0_0'],['0_0','0_0','0_0'],['0_0','0_0','0_0']]
SELECT '--';
--
SELECT arrayMap(x -> concat(concat(concat(concat(concat(toString(id), '___\0_______\0____'), toString(id), concat(concat(toString(id), ''), toString(id)), toString(id)),
arrayMap(x -> concat(concat(concat(concat(toString(id), ''), toString(id)), toString(id), '___\0_______\0____'), toString(id)) AS lambda, [NULL, inf, 1, 1]),
concat(toString(id), NULL), toString(id)), toString(id))) AS lambda, [NULL, NULL, 2147483647])
FROM test_table WHERE concat(concat(concat(toString(id), '___\0_______\0____'), toString(id)), concat(toString(id), NULL), toString(id));
SELECT '--';
--
SELECT arrayMap(x -> concat(toString(id), arrayMap(x -> toString(1), [NULL])), [NULL]) FROM test_table; -- { serverError 44 };
DROP TABLE test_table;