ClickHouse/src/Parsers/ParserCheckQuery.cpp

55 lines
1.3 KiB
C++
Raw Normal View History

#include <Parsers/ParserCheckQuery.h>
#include <Parsers/CommonParsers.h>
#include <Parsers/ASTIdentifier.h>
#include <Parsers/ExpressionElementParsers.h>
#include <Parsers/ASTCheckQuery.h>
2019-07-03 13:17:19 +00:00
#include <Parsers/ParserPartition.h>
2014-08-05 10:52:06 +00:00
2016-11-20 12:43:20 +00:00
namespace DB
{
2014-08-05 10:52:06 +00:00
bool ParserCheckQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
2014-08-05 10:52:06 +00:00
{
ParserKeyword s_check_table("CHECK TABLE");
2019-07-03 13:17:19 +00:00
ParserKeyword s_partition("PARTITION");
ParserToken s_dot(TokenType::Dot);
2014-08-05 10:52:06 +00:00
ParserIdentifier table_parser;
2019-07-03 13:17:19 +00:00
ParserPartition partition_parser;
2014-08-05 10:52:06 +00:00
ASTPtr table;
ASTPtr database;
2014-08-05 10:52:06 +00:00
if (!s_check_table.ignore(pos, expected))
return false;
if (!table_parser.parse(pos, database, expected))
return false;
2014-08-05 10:52:06 +00:00
2019-07-03 13:17:19 +00:00
auto query = std::make_shared<ASTCheckQuery>();
if (s_dot.ignore(pos))
{
if (!table_parser.parse(pos, table, expected))
return false;
2014-08-05 10:52:06 +00:00
2019-08-08 20:02:30 +00:00
tryGetIdentifierNameInto(database, query->database);
tryGetIdentifierNameInto(table, query->table);
}
else
{
table = database;
2019-08-08 20:02:30 +00:00
tryGetIdentifierNameInto(table, query->table);
}
2014-08-05 10:52:06 +00:00
2019-07-03 13:17:19 +00:00
if (s_partition.ignore(pos, expected))
{
if (!partition_parser.parse(pos, query->partition, expected))
return false;
}
node = query;
return true;
2014-08-05 10:52:06 +00:00
}
2016-11-20 12:43:20 +00:00
}