2021-12-03 09:35:36 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Parsers/IAST.h>
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class ASTColumns;
|
|
|
|
class ASTCreateQuery;
|
|
|
|
class ASTIdentifier;
|
|
|
|
class ASTStorage;
|
|
|
|
|
|
|
|
/// Storage and column overrides for a single table, for example:
|
|
|
|
///
|
2021-12-16 08:26:37 +00:00
|
|
|
/// TABLE OVERRIDE `foo` (PARTITION BY toYYYYMM(`createtime`))
|
2021-12-03 09:35:36 +00:00
|
|
|
///
|
|
|
|
class ASTTableOverride : public IAST
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
String table_name;
|
|
|
|
ASTColumns * columns = nullptr;
|
|
|
|
ASTStorage * storage = nullptr;
|
2021-12-16 08:26:37 +00:00
|
|
|
bool is_standalone = true;
|
2021-12-03 09:35:36 +00:00
|
|
|
String getID(char) const override { return "TableOverride " + table_name; }
|
|
|
|
ASTPtr clone() const override;
|
|
|
|
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// List of table overrides, for example:
|
|
|
|
///
|
|
|
|
/// TABLE OVERRIDE `foo` (PARTITION BY toYYYYMM(`createtime`)),
|
|
|
|
/// TABLE OVERRIDE `bar` (SAMPLE BY `id`)
|
|
|
|
///
|
|
|
|
class ASTTableOverrideList : public IAST
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
String getID(char) const override { return "TableOverrideList"; }
|
|
|
|
ASTPtr clone() const override;
|
|
|
|
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
|
2021-12-14 12:34:20 +00:00
|
|
|
void setTableOverride(const String & name, const ASTPtr ast);
|
2021-12-03 09:35:36 +00:00
|
|
|
void removeTableOverride(const String & name);
|
|
|
|
ASTPtr tryGetTableOverride(const String & name) const;
|
|
|
|
bool hasOverride(const String & name) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::map<String, size_t> positions;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|