mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Merge pull request #44413 from save-my-heart/fix_explain_insert_query
fix explain ast insert with data
This commit is contained in:
commit
cd0624e846
@ -3,6 +3,7 @@
|
||||
#include <Interpreters/OpenTelemetrySpanLog.h>
|
||||
#include <Parsers/ParserQuery.h>
|
||||
#include <Parsers/ASTInsertQuery.h>
|
||||
#include <Parsers/ASTExplainQuery.h>
|
||||
#include <Parsers/Lexer.h>
|
||||
#include <Parsers/TokenIterator.h>
|
||||
#include <Common/StringUtils/StringUtils.h>
|
||||
@ -263,7 +264,19 @@ ASTPtr tryParseQuery(
|
||||
|
||||
ASTInsertQuery * insert = nullptr;
|
||||
if (parse_res)
|
||||
{
|
||||
if (auto * explain = res->as<ASTExplainQuery>())
|
||||
{
|
||||
if (auto explained_query = explain->getExplainedQuery())
|
||||
{
|
||||
insert = explained_query->as<ASTInsertQuery>();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
insert = res->as<ASTInsertQuery>();
|
||||
}
|
||||
}
|
||||
|
||||
// If parsed query ends at data for insertion. Data for insertion could be
|
||||
// in any format and not necessary be lexical correct, so we can't perform
|
||||
|
@ -0,0 +1,4 @@
|
||||
InsertQuery (children 1)
|
||||
Identifier test
|
||||
InsertQuery (children 1)
|
||||
Identifier test
|
2
tests/queries/0_stateless/02504_explain_ast_insert.sql
Normal file
2
tests/queries/0_stateless/02504_explain_ast_insert.sql
Normal file
@ -0,0 +1,2 @@
|
||||
explain ast insert into test values balabala;
|
||||
explain ast insert into test format TabSeparated balabala;
|
Loading…
Reference in New Issue
Block a user