ClickHouse/dbms/src/Parsers/ParserDictionary.h

59 lines
2.0 KiB
C++
Raw Normal View History

2019-10-07 16:23:16 +00:00
#pragma once
#include <Parsers/IParser.h>
#include <Parsers/IParserBase.h>
namespace DB
{
2019-10-08 13:26:15 +00:00
/// Parser for dictionary lifetime part. It should contain "lifetime" keyword,
/// opening bracket, literal value or two pairs and closing bracket:
/// lifetime(300), lifetime(min 100 max 200). Produces ASTDictionaryLifetime.
2019-10-07 16:23:16 +00:00
class ParserDictionaryLifetime : public IParserBase
{
protected:
const char * getName() const override { return "lifetime definition"; }
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
};
2019-10-08 13:26:15 +00:00
/// Parser for dictionary range part. It should contain "range" keyword opening
/// bracket, two pairs and closing bracket: range(min attr1 max attr2). Produces
/// ASTDictionaryRange.
2019-10-07 16:23:16 +00:00
class ParserDictionaryRange : public IParserBase
{
protected:
const char * getName() const override { return "range definition"; }
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
};
2019-10-08 13:26:15 +00:00
/// Parser for dictionary layout part. It should contain "layout" keyword,
/// opening bracket, possible pair with param value and closing bracket:
/// layout(type()) or layout(type(param value)). Produces ASTDictionaryLayout.
2019-10-07 16:23:16 +00:00
class ParserDictionaryLayout : public IParserBase
{
protected:
const char * getName() const override { return "layout definition"; }
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
};
2019-10-08 13:26:15 +00:00
/// Combines together all parsers from above and also parses primary key and
/// dictionary source, which consists of custom key-value pairs:
///
/// PRIMARY KEY key_column1, key_column2
/// SOURCE(MYSQL(HOST 'localhost' PORT 9000 USER 'default' REPLICA(HOST '127.0.0.1' PRIORITY 1) PASSWORD ''))
/// LAYOUT(CACHE(size_in_cells 50))
/// LIFETIME(MIN 1 MAX 10)
/// RANGE(MIN second_column MAX third_column)
///
/// Produces ASTDictionary.
2019-10-07 16:23:16 +00:00
class ParserDictionary : public IParserBase
{
protected:
const char * getName() const override { return "dictionary definition"; }
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
};
}