From a6e246b9baedba960928bc4afd30fe8e95a1cec5 Mon Sep 17 00:00:00 2001 From: Vladimir Chebotarev Date: Wed, 14 Apr 2021 11:00:17 +0300 Subject: [PATCH] Parsing. --- src/Parsers/ASTInsertQuery.cpp | 5 +++++ src/Parsers/ASTInsertQuery.h | 2 ++ src/Parsers/ParserInsertQuery.cpp | 1 + 3 files changed, 8 insertions(+) diff --git a/src/Parsers/ASTInsertQuery.cpp b/src/Parsers/ASTInsertQuery.cpp index 39ae5f2a58a..745585ae175 100644 --- a/src/Parsers/ASTInsertQuery.cpp +++ b/src/Parsers/ASTInsertQuery.cpp @@ -25,6 +25,11 @@ void ASTInsertQuery::formatImpl(const FormatSettings & settings, FormatState & s { settings.ostr << (settings.hilite ? hilite_keyword : "") << "FUNCTION "; table_function->formatImpl(settings, state, frame); + if (partition_by) + { + settings.ostr << " PARTITION BY "; + partition_by->formatImpl(settings, state, frame); + } } else settings.ostr << (settings.hilite ? hilite_none : "") diff --git a/src/Parsers/ASTInsertQuery.h b/src/Parsers/ASTInsertQuery.h index e98fe79dedb..6eab3e7acac 100644 --- a/src/Parsers/ASTInsertQuery.h +++ b/src/Parsers/ASTInsertQuery.h @@ -20,6 +20,7 @@ public: ASTPtr infile; ASTPtr watch; ASTPtr table_function; + ASTPtr partition_by; ASTPtr settings_ast; /// Data to insert @@ -44,6 +45,7 @@ public: if (select) { res->select = select->clone(); res->children.push_back(res->select); } if (watch) { res->watch = watch->clone(); res->children.push_back(res->watch); } if (table_function) { res->table_function = table_function->clone(); res->children.push_back(res->table_function); } + if (partition_by) { res->partition_by = partition_by->clone(); res->children.push_back(res->partition_by); } if (settings_ast) { res->settings_ast = settings_ast->clone(); res->children.push_back(res->settings_ast); } return res; diff --git a/src/Parsers/ParserInsertQuery.cpp b/src/Parsers/ParserInsertQuery.cpp index 2eca6dbcdd4..19457f027bf 100644 --- a/src/Parsers/ParserInsertQuery.cpp +++ b/src/Parsers/ParserInsertQuery.cpp @@ -193,6 +193,7 @@ bool ParserInsertQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected) if (table_function) { query->table_function = table_function; + query->partition_by = partition_by_expr; } else {