mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 09:32:01 +00:00
Merge pull request #38910 from ClickHouse/explain_ast_after_rewrite
EXPLAIN AST rewrite option
This commit is contained in:
commit
01bbfd86ad
@ -146,12 +146,14 @@ namespace
|
||||
struct QueryASTSettings
|
||||
{
|
||||
bool graph = false;
|
||||
bool rewrite = false;
|
||||
|
||||
constexpr static char name[] = "AST";
|
||||
|
||||
std::unordered_map<std::string, std::reference_wrapper<bool>> boolean_settings =
|
||||
{
|
||||
{"graph", graph},
|
||||
{"rewrite", rewrite}
|
||||
};
|
||||
};
|
||||
|
||||
@ -278,6 +280,12 @@ QueryPipeline InterpreterExplainQuery::executeImpl()
|
||||
case ASTExplainQuery::ParsedAST:
|
||||
{
|
||||
auto settings = checkAndGetSettings<QueryASTSettings>(ast.getSettings());
|
||||
if (settings.rewrite)
|
||||
{
|
||||
ExplainAnalyzedSyntaxVisitor::Data data(getContext());
|
||||
ExplainAnalyzedSyntaxVisitor(data).visit(query);
|
||||
}
|
||||
|
||||
if (settings.graph)
|
||||
dumpASTInDotFormat(*ast.getExplainedQuery(), buf);
|
||||
else
|
||||
|
@ -0,0 +1,25 @@
|
||||
-- { echoOn }
|
||||
EXPLAIN AST rewrite=0 SELECT * FROM numbers(0);
|
||||
SelectWithUnionQuery (children 1)
|
||||
ExpressionList (children 1)
|
||||
SelectQuery (children 2)
|
||||
ExpressionList (children 1)
|
||||
Asterisk
|
||||
TablesInSelectQuery (children 1)
|
||||
TablesInSelectQueryElement (children 1)
|
||||
TableExpression (children 1)
|
||||
Function numbers (children 1)
|
||||
ExpressionList (children 1)
|
||||
Literal UInt64_0
|
||||
EXPLAIN AST rewrite=1 SELECT * FROM numbers(0);
|
||||
SelectWithUnionQuery (children 1)
|
||||
ExpressionList (children 1)
|
||||
SelectQuery (children 2)
|
||||
ExpressionList (children 1)
|
||||
Identifier number
|
||||
TablesInSelectQuery (children 1)
|
||||
TablesInSelectQueryElement (children 1)
|
||||
TableExpression (children 1)
|
||||
Function numbers (children 1)
|
||||
ExpressionList (children 1)
|
||||
Literal UInt64_0
|
4
tests/queries/0_stateless/02353_explain_ast_rewrite.sql
Normal file
4
tests/queries/0_stateless/02353_explain_ast_rewrite.sql
Normal file
@ -0,0 +1,4 @@
|
||||
-- { echoOn }
|
||||
EXPLAIN AST rewrite=0 SELECT * FROM numbers(0);
|
||||
EXPLAIN AST rewrite=1 SELECT * FROM numbers(0);
|
||||
-- { echoOff }
|
Loading…
Reference in New Issue
Block a user