mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-18 04:12:19 +00:00
fd42d1ee87
Trying to resurrect https://github.com/ClickHouse/ClickHouse/pull/7533. I'd like to get this PR in if we have an agreement on syntax and general direction, after that I'll rebase actual alter functionality from above mentioned PR.
91 lines
2.7 KiB
C++
91 lines
2.7 KiB
C++
#pragma once
|
|
|
|
#include <Parsers/ASTQueryWithTableAndOutput.h>
|
|
#include <Parsers/ASTQueryWithOnCluster.h>
|
|
#include <Parsers/ASTDictionary.h>
|
|
#include <Parsers/ASTDictionaryAttributeDeclaration.h>
|
|
#include <Parsers/ASTSelectWithUnionQuery.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
class ASTFunction;
|
|
class ASTSetQuery;
|
|
|
|
class ASTStorage : public IAST
|
|
{
|
|
public:
|
|
ASTFunction * engine = nullptr;
|
|
IAST * partition_by = nullptr;
|
|
IAST * primary_key = nullptr;
|
|
IAST * order_by = nullptr;
|
|
IAST * sample_by = nullptr;
|
|
IAST * ttl_table = nullptr;
|
|
ASTSetQuery * settings = nullptr;
|
|
|
|
String getID(char) const override { return "Storage definition"; }
|
|
|
|
ASTPtr clone() const override;
|
|
|
|
void formatImpl(const FormatSettings & s, FormatState & state, FormatStateStacked frame) const override;
|
|
};
|
|
|
|
|
|
class ASTExpressionList;
|
|
|
|
class ASTColumns : public IAST
|
|
{
|
|
public:
|
|
ASTExpressionList * columns = nullptr;
|
|
ASTExpressionList * indices = nullptr;
|
|
ASTExpressionList * constraints = nullptr;
|
|
|
|
String getID(char) const override { return "Columns definition"; }
|
|
|
|
ASTPtr clone() const override;
|
|
|
|
void formatImpl(const FormatSettings & s, FormatState & state, FormatStateStacked frame) const override;
|
|
};
|
|
|
|
|
|
/// CREATE TABLE or ATTACH TABLE query
|
|
class ASTCreateQuery : public ASTQueryWithTableAndOutput, public ASTQueryWithOnCluster
|
|
{
|
|
public:
|
|
bool attach{false}; /// Query ATTACH TABLE, not CREATE TABLE.
|
|
bool if_not_exists{false};
|
|
bool is_view{false};
|
|
bool is_materialized_view{false};
|
|
bool is_live_view{false};
|
|
bool is_populate{false};
|
|
bool is_dictionary{false}; /// CREATE DICTIONARY
|
|
bool replace_view{false}; /// CREATE OR REPLACE VIEW
|
|
ASTColumns * columns_list = nullptr;
|
|
ASTExpressionList * dictionary_attributes_list = nullptr; /// attributes of dictionary
|
|
ASTExpressionList * tables = nullptr;
|
|
String to_database; /// For CREATE MATERIALIZED VIEW mv TO table.
|
|
String to_table;
|
|
ASTStorage * storage = nullptr;
|
|
String as_database;
|
|
String as_table;
|
|
ASTPtr as_table_function;
|
|
ASTSelectWithUnionQuery * select = nullptr;
|
|
ASTDictionary * dictionary = nullptr; /// dictionary definition (layout, primary key, etc.)
|
|
|
|
/** Get the text that identifies this element. */
|
|
String getID(char delim) const override { return (attach ? "AttachQuery" : "CreateQuery") + (delim + database) + delim + table; }
|
|
|
|
ASTPtr clone() const override;
|
|
|
|
ASTPtr getRewrittenASTWithoutOnCluster(const std::string & new_database) const override
|
|
{
|
|
return removeOnCluster<ASTCreateQuery>(clone(), new_database);
|
|
}
|
|
|
|
protected:
|
|
void formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
|
|
};
|
|
|
|
}
|