Added EXPLAIN QUERY TREE tests

This commit is contained in:
Maksim Kita 2022-07-19 15:25:15 +02:00
parent 603c4febc3
commit 425eb16514
2 changed files with 133 additions and 0 deletions

View File

@ -0,0 +1,95 @@
QUERY id: 0, is_subquery: 0, is_cte: 0
PROJECTION
LIST id: 1, nodes: 1
CONSTANT id: 2, value: UInt64_1, result_type: UInt8
JOIN TREE
IDENTIFIER id: 3, identifier: system.one
--
QUERY id: 0, is_subquery: 0, is_cte: 0
PROJECTION
LIST id: 1, nodes: 2
IDENTIFIER id: 2, identifier: id
IDENTIFIER id: 3, identifier: value
JOIN TREE
IDENTIFIER id: 4, identifier: test_table
--
QUERY id: 0, is_subquery: 0, is_cte: 0
PROJECTION
LIST id: 1, nodes: 2
COLUMN id: 2, column_name: id, result_type: UInt64, source_id: 3
COLUMN id: 4, column_name: value, result_type: String, source_id: 3
JOIN TREE
TABLE id: 3, table_name: default.test_table
--
QUERY id: 0, is_subquery: 0, is_cte: 0
PROJECTION
LIST id: 1, nodes: 1
FUNCTION id: 2, function_name: arrayMap
ARGUMENTS
LIST id: 3, nodes: 2
LAMBDA id: 4
ARGUMENTS
LIST id: 5, nodes: 1
IDENTIFIER id: 6, identifier: x
EXPRESSION
FUNCTION id: 7, function_name: plus
ARGUMENTS
LIST id: 8, nodes: 2
IDENTIFIER id: 9, identifier: x
IDENTIFIER id: 10, identifier: id
CONSTANT id: 11, value: Array_[UInt64_1, UInt64_2, UInt64_3], result_type: Array(UInt8)
JOIN TREE
IDENTIFIER id: 12, identifier: test_table
--
QUERY id: 0, is_subquery: 0, is_cte: 0
PROJECTION
LIST id: 1, nodes: 1
FUNCTION id: 2, function_name: arrayMap, result_type: Array(UInt16)
ARGUMENTS
LIST id: 3, nodes: 2
LAMBDA id: 4, result_type: UInt16
ARGUMENTS
LIST id: 5, nodes: 1
COLUMN id: 6, column_name: x, result_type: UInt8, source_id: 4
EXPRESSION
FUNCTION id: 7, function_name: plus, result_type: UInt16
ARGUMENTS
LIST id: 8, nodes: 2
COLUMN id: 6, column_name: x, result_type: UInt8, source_id: 4
CONSTANT id: 9, value: UInt64_1, result_type: UInt8
CONSTANT id: 10, value: Array_[UInt64_1, UInt64_2, UInt64_3], result_type: Array(UInt8)
JOIN TREE
TABLE id: 11, table_name: default.test_table
--
QUERY id: 0, is_subquery: 0, is_cte: 0
WITH
LIST id: 1, nodes: 1
LAMBDA id: 2, alias: lambda
ARGUMENTS
LIST id: 3, nodes: 1
IDENTIFIER id: 4, identifier: x
EXPRESSION
FUNCTION id: 5, function_name: plus
ARGUMENTS
LIST id: 6, nodes: 2
IDENTIFIER id: 7, identifier: x
CONSTANT id: 8, value: UInt64_1, result_type: UInt8
PROJECTION
LIST id: 9, nodes: 1
FUNCTION id: 10, function_name: lambda
ARGUMENTS
LIST id: 11, nodes: 1
IDENTIFIER id: 12, identifier: id
JOIN TREE
IDENTIFIER id: 13, identifier: test_table
--
QUERY id: 0, is_subquery: 0, is_cte: 0
PROJECTION
LIST id: 1, nodes: 1
FUNCTION id: 2, function_name: plus, result_type: UInt64
ARGUMENTS
LIST id: 3, nodes: 2
COLUMN id: 4, column_name: id, result_type: UInt64, source_id: 5
CONSTANT id: 6, value: UInt64_1, result_type: UInt8
JOIN TREE
TABLE id: 5, table_name: default.test_table

View File

@ -0,0 +1,38 @@
SET use_analyzer = 1;
EXPLAIN QUERY TREE SELECT 1;
SELECT '--';
DROP TABLE IF EXISTS test_table;
CREATE TABLE test_table
(
id UInt64,
value String
) ENGINE=TinyLog;
INSERT INTO test_table VALUES (0, 'Value');
EXPLAIN QUERY TREE SELECT id, value FROM test_table;
SELECT '--';
EXPLAIN QUERY TREE run_passes = 1 SELECT id, value FROM test_table;
SELECT '--';
EXPLAIN QUERY TREE SELECT arrayMap(x -> x + id, [1, 2, 3]) FROM test_table;
SELECT '--';
EXPLAIN QUERY TREE run_passes = 1 SELECT arrayMap(x -> x + 1, [1, 2, 3]) FROM test_table;
SELECT '--';
EXPLAIN QUERY TREE WITH x -> x + 1 AS lambda SELECT lambda(id) FROM test_table;
SELECT '--';
EXPLAIN QUERY TREE run_passes = 1 WITH x -> x + 1 AS lambda SELECT lambda(id) FROM test_table;
DROP TABLE test_table;