Merge pull request #44413 from save-my-heart/fix_explain_insert_query

fix explain ast insert with data
This commit is contained in:
Han Fei 2022-12-28 18:08:49 +01:00 committed by GitHub
commit cd0624e846
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 1 deletions

View File

@ -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

View File

@ -0,0 +1,4 @@
InsertQuery (children 1)
Identifier test
InsertQuery (children 1)
Identifier test

View File

@ -0,0 +1,2 @@
explain ast insert into test values balabala;
explain ast insert into test format TabSeparated balabala;