aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Parsers/ParserDescribeCacheQuery.cpp
blob: c6c9cbe8bc0e3415eeba2bbfb778b0020da200e9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <Parsers/ParserDescribeCacheQuery.h>
#include <Parsers/ASTDescribeCacheQuery.h>
#include <Parsers/CommonParsers.h>
#include <Parsers/ASTLiteral.h>

namespace DB
{


bool ParserDescribeCacheQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
{
    ParserKeyword p_describe("DESCRIBE");
    ParserKeyword p_desc("DESC");
    ParserKeyword p_cache("FILESYSTEM CACHE");
    ParserLiteral p_cache_name;

    if ((!p_describe.ignore(pos, expected) && !p_desc.ignore(pos, expected))
        || !p_cache.ignore(pos, expected))
        return false;

    auto query = std::make_shared<ASTDescribeCacheQuery>();

    ASTPtr ast;
    if (!p_cache_name.parse(pos, ast, expected))
        return false;

    query->cache_name = ast->as<ASTLiteral>()->value.safeGet<String>();
    node = query;

    return true;
}


}