| 1 | #pragma once | 
|---|
| 2 |  | 
|---|
| 3 | #include <Parsers/IParser.h> | 
|---|
| 4 | #include <Parsers/IParserBase.h> | 
|---|
| 5 |  | 
|---|
| 6 | namespace DB | 
|---|
| 7 | { | 
|---|
| 8 |  | 
|---|
| 9 | /// Parser for dictionary lifetime part. It should contain "lifetime" keyword, | 
|---|
| 10 | /// opening bracket, literal value or two pairs and closing bracket: | 
|---|
| 11 | /// lifetime(300), lifetime(min 100 max 200). Produces ASTDictionaryLifetime. | 
|---|
| 12 | class ParserDictionaryLifetime : public IParserBase | 
|---|
| 13 | { | 
|---|
| 14 | protected: | 
|---|
| 15 | const char * getName() const override { return "lifetime definition"; } | 
|---|
| 16 | bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override; | 
|---|
| 17 | }; | 
|---|
| 18 |  | 
|---|
| 19 | /// Parser for dictionary range part. It should contain "range" keyword opening | 
|---|
| 20 | /// bracket, two pairs and closing bracket: range(min attr1 max attr2). Produces | 
|---|
| 21 | /// ASTDictionaryRange. | 
|---|
| 22 | class ParserDictionaryRange : public IParserBase | 
|---|
| 23 | { | 
|---|
| 24 | protected: | 
|---|
| 25 | const char * getName() const override { return "range definition"; } | 
|---|
| 26 | bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override; | 
|---|
| 27 | }; | 
|---|
| 28 |  | 
|---|
| 29 |  | 
|---|
| 30 | /// Parser for dictionary layout part. It should contain "layout" keyword, | 
|---|
| 31 | /// opening bracket, possible pair with param value and closing bracket: | 
|---|
| 32 | /// layout(type()) or layout(type(param value)). Produces ASTDictionaryLayout. | 
|---|
| 33 | class ParserDictionaryLayout : public IParserBase | 
|---|
| 34 | { | 
|---|
| 35 | protected: | 
|---|
| 36 | const char * getName() const override { return "layout definition"; } | 
|---|
| 37 | bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override; | 
|---|
| 38 | }; | 
|---|
| 39 |  | 
|---|
| 40 |  | 
|---|
| 41 | /// Combines together all parsers from above and also parses primary key and | 
|---|
| 42 | /// dictionary source, which consists of custom key-value pairs: | 
|---|
| 43 | /// | 
|---|
| 44 | /// PRIMARY KEY key_column1, key_column2 | 
|---|
| 45 | /// SOURCE(MYSQL(HOST 'localhost' PORT 9000 USER 'default' REPLICA(HOST '127.0.0.1' PRIORITY 1) PASSWORD '')) | 
|---|
| 46 | /// LAYOUT(CACHE(size_in_cells 50)) | 
|---|
| 47 | /// LIFETIME(MIN 1 MAX 10) | 
|---|
| 48 | /// RANGE(MIN second_column MAX third_column) | 
|---|
| 49 | /// | 
|---|
| 50 | /// Produces ASTDictionary. | 
|---|
| 51 | class ParserDictionary : public IParserBase | 
|---|
| 52 | { | 
|---|
| 53 | protected: | 
|---|
| 54 | const char * getName() const override { return "dictionary definition"; } | 
|---|
| 55 | bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override; | 
|---|
| 56 | }; | 
|---|
| 57 |  | 
|---|
| 58 | } | 
|---|
| 59 |  | 
|---|