ClickHouse/tests/queries/0_stateless/02421_explain_subquery.sql

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

86 lines
4.7 KiB
MySQL
Raw Normal View History

SET allow_experimental_analyzer = 0;
2022-09-28 12:30:45 +00:00
SELECT count() > 3 FROM (EXPLAIN PIPELINE header = 1 SELECT * FROM system.numbers ORDER BY number DESC) WHERE explain LIKE '%Header: number UInt64%';
SELECT count() > 0 FROM (EXPLAIN PLAN SELECT * FROM system.numbers ORDER BY number DESC) WHERE explain ILIKE '%Sort%';
SELECT count() > 0 FROM (EXPLAIN SELECT * FROM system.numbers ORDER BY number DESC) WHERE explain ILIKE '%Sort%';
2022-09-28 13:09:53 +00:00
SELECT count() > 0 FROM (EXPLAIN CURRENT TRANSACTION);
SELECT count() == 1 FROM (EXPLAIN SYNTAX SELECT number FROM system.numbers ORDER BY number DESC) WHERE explain ILIKE 'SELECT%';
2022-09-28 12:30:45 +00:00
SELECT trim(explain) == 'Asterisk' FROM (EXPLAIN AST SELECT * FROM system.numbers LIMIT 10) WHERE explain LIKE '%Asterisk%';
2022-09-28 13:09:53 +00:00
SELECT * FROM (
EXPLAIN AST SELECT * FROM (
EXPLAIN PLAN SELECT * FROM (
EXPLAIN SYNTAX SELECT trim(explain) == 'Asterisk' FROM (
EXPLAIN AST SELECT * FROM system.numbers LIMIT 10
) WHERE explain LIKE '%Asterisk%'
)
)
) FORMAT Null;
2023-01-13 12:19:25 +00:00
SELECT (EXPLAIN SYNTAX oneline = 1 SELECT 1) == 'SELECT 1';
SELECT * FROM viewExplain('', ''); -- { serverError BAD_ARGUMENTS }
SELECT * FROM viewExplain('EXPLAIN AST', ''); -- { serverError BAD_ARGUMENTS }
SELECT * FROM viewExplain('EXPLAIN AST', '', 1); -- { serverError BAD_ARGUMENTS }
SELECT * FROM viewExplain('EXPLAIN AST', '', ''); -- { serverError BAD_ARGUMENTS }
2022-09-28 13:09:53 +00:00
CREATE TABLE t1 ( a UInt64 ) Engine = MergeTree ORDER BY tuple() AS SELECT number AS a FROM system.numbers LIMIT 100000;
SELECT rows > 1000 FROM (EXPLAIN ESTIMATE SELECT sum(a) FROM t1);
SELECT count() == 1 FROM (EXPLAIN ESTIMATE SELECT sum(a) FROM t1);
DROP TABLE IF EXISTS t1;
SET allow_experimental_analyzer = 1;
SELECT count() > 3 FROM (EXPLAIN PIPELINE header = 1 SELECT * FROM system.numbers ORDER BY number DESC) WHERE explain LIKE '%Header: system.numbers.number__ UInt64%';
SELECT count() > 0 FROM (EXPLAIN PLAN SELECT * FROM system.numbers ORDER BY number DESC) WHERE explain ILIKE '%Sort%';
SELECT count() > 0 FROM (EXPLAIN SELECT * FROM system.numbers ORDER BY number DESC) WHERE explain ILIKE '%Sort%';
SELECT count() > 0 FROM (EXPLAIN CURRENT TRANSACTION);
SELECT count() == 1 FROM (EXPLAIN SYNTAX SELECT number FROM system.numbers ORDER BY number DESC) WHERE explain ILIKE 'SELECT%';
2023-01-10 12:08:57 +00:00
-- We have `Identifier number` instead of `Asterisk` because query argument of `viewExplain` table function was analyzed.
-- Compare:
-- :) EXPLAIN AST SELECT *;
-- ┌─explain───────────────────────────┐
-- │ SelectWithUnionQuery (children 1) │
-- │ ExpressionList (children 1) │
-- │ SelectQuery (children 1) │
-- │ ExpressionList (children 1) │
-- │ Asterisk │
-- └───────────────────────────────────┘
-- :) SELECT * FROM (EXPLAIN AST SELECT *);
-- ┌─explain─────────────────────────────────────┐
-- │ SelectWithUnionQuery (children 1) │
-- │ ExpressionList (children 1) │
-- │ SelectQuery (children 2) │
-- │ ExpressionList (children 1) │
-- │ Identifier dummy │
-- │ TablesInSelectQuery (children 1) │
-- │ TablesInSelectQueryElement (children 1) │
-- │ TableExpression (children 1) │
-- │ TableIdentifier system.one │
-- └─────────────────────────────────────────────┘
-- TODO: argument of `viewExplain` (and subquery in `EXAPLAN ...`) should not be analyzed.
-- See _Support query tree in table functions_ in https://github.com/ClickHouse/ClickHouse/issues/42648
SELECT trim(explain) == 'Identifier number' FROM (EXPLAIN AST SELECT * FROM system.numbers LIMIT 10) WHERE explain LIKE '%Identifier number%';
SELECT * FROM (
EXPLAIN AST SELECT * FROM (
EXPLAIN PLAN SELECT * FROM (
EXPLAIN SYNTAX SELECT trim(explain) == 'Asterisk' FROM (
EXPLAIN AST SELECT * FROM system.numbers LIMIT 10
) WHERE explain LIKE '%Asterisk%'
)
)
) FORMAT Null;
2023-01-13 12:19:25 +00:00
SELECT (EXPLAIN SYNTAX oneline = 1 SELECT 1) == 'SELECT 1 FROM system.one';
SELECT * FROM viewExplain('', ''); -- { serverError BAD_ARGUMENTS }
SELECT * FROM viewExplain('EXPLAIN AST', ''); -- { serverError BAD_ARGUMENTS }
SELECT * FROM viewExplain('EXPLAIN AST', '', 1); -- { serverError BAD_ARGUMENTS }
SELECT * FROM viewExplain('EXPLAIN AST', '', ''); -- { serverError BAD_ARGUMENTS }
-- EXPLAIN ESTIMATE is not supported in experimental analyzer