2019-10-01 14:54:28 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Parsers/IAST.h>
|
|
|
|
#include <Parsers/ASTFunctionWithKeyValueArguments.h>
|
|
|
|
#include <Parsers/ASTLiteral.h>
|
2019-10-07 16:23:16 +00:00
|
|
|
#include <Parsers/ASTExpressionList.h>
|
2019-10-01 14:54:28 +00:00
|
|
|
|
2020-04-23 12:39:27 +00:00
|
|
|
#include <Parsers/ASTSetQuery.h>
|
|
|
|
|
|
|
|
#include <Parsers/ParserSetQuery.h>
|
|
|
|
|
2019-10-01 14:54:28 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2019-10-08 13:26:15 +00:00
|
|
|
/// AST for external dictionary lifetime:
|
|
|
|
/// lifetime(min 10 max 100)
|
2019-10-01 14:54:28 +00:00
|
|
|
class ASTDictionaryLifetime : public IAST
|
|
|
|
{
|
|
|
|
public:
|
2019-10-07 16:23:16 +00:00
|
|
|
UInt64 min_sec = 0;
|
|
|
|
UInt64 max_sec = 0;
|
2019-10-01 14:54:28 +00:00
|
|
|
|
|
|
|
String getID(char) const override { return "Dictionary lifetime"; }
|
|
|
|
|
|
|
|
ASTPtr clone() const override;
|
|
|
|
|
|
|
|
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
|
|
|
|
};
|
|
|
|
|
2019-10-08 13:26:15 +00:00
|
|
|
/// AST for external dictionary layout. Has name and contain single parameter
|
|
|
|
/// layout(type()) or layout(type(param value))
|
2019-10-01 14:54:28 +00:00
|
|
|
class ASTDictionaryLayout : public IAST
|
|
|
|
{
|
|
|
|
using KeyValue = std::pair<std::string, ASTLiteral *>;
|
|
|
|
public:
|
2019-10-08 13:26:15 +00:00
|
|
|
/// flat, cache, hashed, etc.
|
2019-10-01 14:54:28 +00:00
|
|
|
String layout_type;
|
2020-04-22 07:27:20 +00:00
|
|
|
/// parameters (size_in_cells, ...)
|
2020-01-05 13:59:49 +00:00
|
|
|
std::vector<KeyValue> parameters;
|
2020-04-06 11:02:17 +00:00
|
|
|
/// has brackets after layout type
|
|
|
|
bool has_brackets = true;
|
2019-10-01 14:54:28 +00:00
|
|
|
|
|
|
|
String getID(char) const override { return "Dictionary layout"; }
|
|
|
|
|
|
|
|
ASTPtr clone() const override;
|
|
|
|
|
|
|
|
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-10-08 13:26:15 +00:00
|
|
|
/// AST for external range-hashed dictionary
|
|
|
|
/// Range bounded with two attributes from minimum to maximum
|
|
|
|
/// RANGE(min attr1 max attr2)
|
2019-10-01 14:54:28 +00:00
|
|
|
class ASTDictionaryRange : public IAST
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
String min_attr_name;
|
|
|
|
String max_attr_name;
|
|
|
|
|
|
|
|
String getID(char) const override { return "Dictionary range"; }
|
|
|
|
|
|
|
|
ASTPtr clone() const override;
|
|
|
|
|
|
|
|
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
|
|
|
|
};
|
|
|
|
|
2020-04-23 20:50:01 +00:00
|
|
|
class ASTDictionarySettings : public IAST
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SettingsChanges changes;
|
|
|
|
|
|
|
|
String getID(char) const override { return "Dictionary settings"; }
|
|
|
|
|
2020-04-26 17:24:18 +00:00
|
|
|
ASTPtr clone() const override;
|
2020-04-23 20:50:01 +00:00
|
|
|
|
|
|
|
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
|
|
|
|
};
|
|
|
|
|
2019-10-01 14:54:28 +00:00
|
|
|
|
2019-10-08 13:26:15 +00:00
|
|
|
/// AST contains all parts of external dictionary definition except attributes
|
2019-10-01 14:54:28 +00:00
|
|
|
class ASTDictionary : public IAST
|
|
|
|
{
|
|
|
|
public:
|
2019-10-08 13:26:15 +00:00
|
|
|
/// Dictionary keys -- one or more
|
2020-07-31 15:39:45 +00:00
|
|
|
ASTExpressionList * primary_key = nullptr;
|
2019-10-08 13:26:15 +00:00
|
|
|
/// Dictionary external source, doesn't have own AST, because
|
|
|
|
/// source parameters absolutely different for different sources
|
2020-07-31 15:39:45 +00:00
|
|
|
ASTFunctionWithKeyValueArguments * source = nullptr;
|
2019-10-08 13:26:15 +00:00
|
|
|
|
|
|
|
/// Lifetime of dictionary (required part)
|
2020-07-31 15:39:45 +00:00
|
|
|
ASTDictionaryLifetime * lifetime = nullptr;
|
2019-10-08 13:26:15 +00:00
|
|
|
/// Layout of dictionary (required part)
|
2020-07-31 15:39:45 +00:00
|
|
|
ASTDictionaryLayout * layout = nullptr;
|
2019-10-08 13:26:15 +00:00
|
|
|
/// Range for dictionary (only for range-hashed dictionaries)
|
2020-07-31 15:39:45 +00:00
|
|
|
ASTDictionaryRange * range = nullptr;
|
2020-04-23 12:39:27 +00:00
|
|
|
/// Settings for dictionary (optionally)
|
2020-07-31 15:39:45 +00:00
|
|
|
ASTDictionarySettings * dict_settings = nullptr;
|
2019-10-01 14:54:28 +00:00
|
|
|
|
|
|
|
String getID(char) const override { return "Dictionary definition"; }
|
|
|
|
|
|
|
|
ASTPtr clone() const override;
|
|
|
|
|
|
|
|
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|