mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 17:41:59 +00:00
Fix viewExplain, add testcases
This commit is contained in:
parent
bdb9222736
commit
f881a82417
@ -123,8 +123,8 @@ bool ParserSubquery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
||||
if (explain_query.getTableFunction() || explain_query.getTableOverride())
|
||||
throw Exception("EXPLAIN in a subquery cannot have a table function or table override", ErrorCodes::BAD_ARGUMENTS);
|
||||
|
||||
/// Replace `SELECT * FROM (EXPLAIN <kind> <explain_settings> SELECT ...)`
|
||||
/// with `SELECT * FROM viewExplain("<kind>", "<explain_settings>", SELECT ...)`
|
||||
/// Replace subquery `(EXPLAIN <kind> <explain_settings> SELECT ...)`
|
||||
/// with `(SELECT * FROM viewExplain("<kind>", "<explain_settings>", SELECT ...))`
|
||||
|
||||
String kind_str = ASTExplainQuery::toString(explain_query.getKind());
|
||||
|
||||
|
@ -69,6 +69,10 @@ void TableFunctionExplain::parseArguments(const ASTPtr & ast_function, ContextPt
|
||||
getName(), queryToString(query_arg));
|
||||
explain_query->setExplainedQuery(query_arg);
|
||||
}
|
||||
else if (kind != ASTExplainQuery::ExplainKind::CurrentTransaction)
|
||||
{
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Table function '{}' requires a query argument", getName());
|
||||
}
|
||||
|
||||
query = std::move(explain_query);
|
||||
}
|
||||
|
@ -12,3 +12,5 @@
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
|
@ -17,6 +17,13 @@ SELECT * FROM (
|
||||
)
|
||||
) FORMAT Null;
|
||||
|
||||
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 }
|
||||
|
||||
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);
|
||||
@ -68,4 +75,11 @@ SELECT * FROM (
|
||||
)
|
||||
) FORMAT Null;
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user