aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Parsers/ParserDictionary.h
blob: a38fd18dbcd322970b27e6ce5ce5f15fa0694368 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#pragma once

#include <Parsers/IParserBase.h>

#include <Parsers/ParserSetQuery.h>

namespace DB
{

/// 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.
class ParserDictionaryLifetime : public IParserBase
{
protected:
    const char * getName() const override { return "lifetime definition"; }
    bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
};

/// Parser for dictionary range part. It should contain "range" keyword opening
/// bracket, two pairs and closing bracket: range(min attr1 max attr2). Produces
/// ASTDictionaryRange.
class ParserDictionaryRange : public IParserBase
{
protected:
    const char * getName() const override { return "range definition"; }
    bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
};


/// 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.
class ParserDictionaryLayout : public IParserBase
{
protected:
    const char * getName() const override { return "layout definition"; }
    bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
};

class ParserDictionarySettings: public IParserBase
{
protected:
    const char * getName() const override { return "settings definition"; }
    bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
};


/// 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.
class ParserDictionary : public IParserBase
{
protected:
    const char * getName() const override { return "dictionary definition"; }
    bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
};

}