2022-06-08 17:14:03 +00:00
|
|
|
#include <Parsers/IParserBase.h>
|
|
|
|
#include <Parsers/ParserSetQuery.h>
|
|
|
|
#include <Parsers/ASTExpressionList.h>
|
|
|
|
#include <Parsers/ASTSelectWithUnionQuery.h>
|
|
|
|
#include <Parsers/Kusto/ParserKQLQuery.h>
|
|
|
|
#include <Parsers/Kusto/ParserKQLStatement.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
bool ParserKQLStatement::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
|
|
|
{
|
|
|
|
ParserKQLWithOutput query_with_output_p(end, allow_settings_after_format_in_insert);
|
|
|
|
ParserSetQuery set_p;
|
|
|
|
|
|
|
|
bool res = query_with_output_p.parse(pos, node, expected)
|
|
|
|
|| set_p.parse(pos, node, expected);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ParserKQLWithOutput::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
|
|
|
{
|
2022-06-08 17:14:03 +00:00
|
|
|
ParserKQLWithUnionQuery KQL_p;
|
2022-06-08 17:14:03 +00:00
|
|
|
|
|
|
|
ASTPtr query;
|
2022-06-08 17:14:03 +00:00
|
|
|
bool parsed = KQL_p.parse(pos, query, expected);
|
2022-06-08 17:14:03 +00:00
|
|
|
|
|
|
|
if (!parsed)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
node = std::move(query);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ParserKQLWithUnionQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
|
|
|
{
|
2022-06-08 17:14:03 +00:00
|
|
|
// will support union next phase
|
|
|
|
ASTPtr KQLQuery;
|
2022-06-08 17:14:03 +00:00
|
|
|
|
2022-06-08 17:14:03 +00:00
|
|
|
if (!ParserKQLQuery().parse(pos, KQLQuery, expected))
|
2022-06-08 17:14:03 +00:00
|
|
|
return false;
|
|
|
|
|
2022-06-08 17:14:03 +00:00
|
|
|
if (KQLQuery->as<ASTSelectWithUnionQuery>())
|
2022-06-08 17:14:03 +00:00
|
|
|
{
|
2022-06-08 17:14:03 +00:00
|
|
|
node = std::move(KQLQuery);
|
2022-06-08 17:14:03 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto list_node = std::make_shared<ASTExpressionList>();
|
2022-06-08 17:14:03 +00:00
|
|
|
list_node->children.push_back(KQLQuery);
|
2022-06-08 17:14:03 +00:00
|
|
|
|
|
|
|
auto select_with_union_query = std::make_shared<ASTSelectWithUnionQuery>();
|
|
|
|
node = select_with_union_query;
|
|
|
|
select_with_union_query->list_of_selects = list_node;
|
|
|
|
select_with_union_query->children.push_back(select_with_union_query->list_of_selects);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|