2011-08-18 18:48:00 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-10-18 15:03:14 +00:00
|
|
|
#include <Parsers/ASTQueryWithTableAndOutput.h>
|
2017-04-21 12:39:28 +00:00
|
|
|
#include <Parsers/ASTQueryWithOnCluster.h>
|
2019-10-01 14:54:28 +00:00
|
|
|
#include <Parsers/ASTDictionary.h>
|
|
|
|
#include <Parsers/ASTDictionaryAttributeDeclaration.h>
|
2011-08-18 18:48:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2019-03-23 22:45:28 +00:00
|
|
|
class ASTFunction;
|
|
|
|
class ASTSetQuery;
|
|
|
|
|
2017-09-17 18:49:43 +00:00
|
|
|
class ASTStorage : public IAST
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ASTFunction * engine = nullptr;
|
2017-09-18 14:18:29 +00:00
|
|
|
IAST * partition_by = nullptr;
|
2018-10-10 18:24:11 +00:00
|
|
|
IAST * primary_key = nullptr;
|
2017-09-18 14:18:29 +00:00
|
|
|
IAST * order_by = nullptr;
|
|
|
|
IAST * sample_by = nullptr;
|
2019-04-15 09:30:45 +00:00
|
|
|
IAST * ttl_table = nullptr;
|
2017-09-18 14:18:29 +00:00
|
|
|
ASTSetQuery * settings = nullptr;
|
2017-09-17 18:49:43 +00:00
|
|
|
|
2018-12-07 12:34:40 +00:00
|
|
|
String getID(char) const override { return "Storage definition"; }
|
2017-09-17 18:49:43 +00:00
|
|
|
|
2019-03-23 22:45:28 +00:00
|
|
|
ASTPtr clone() const override;
|
2017-09-17 18:49:43 +00:00
|
|
|
|
2019-03-23 22:45:28 +00:00
|
|
|
void formatImpl(const FormatSettings & s, FormatState & state, FormatStateStacked frame) const override;
|
2017-09-17 18:49:43 +00:00
|
|
|
};
|
|
|
|
|
2011-08-18 18:48:00 +00:00
|
|
|
|
2019-03-23 22:45:28 +00:00
|
|
|
class ASTExpressionList;
|
2019-02-05 14:50:25 +00:00
|
|
|
|
2019-03-23 22:45:28 +00:00
|
|
|
class ASTColumns : public IAST
|
|
|
|
{
|
2019-02-05 14:50:25 +00:00
|
|
|
public:
|
|
|
|
ASTExpressionList * columns = nullptr;
|
|
|
|
ASTExpressionList * indices = nullptr;
|
2019-05-12 11:36:02 +00:00
|
|
|
ASTExpressionList * constraints = nullptr;
|
2019-02-05 14:50:25 +00:00
|
|
|
|
|
|
|
String getID(char) const override { return "Columns definition"; }
|
|
|
|
|
2019-03-23 22:45:28 +00:00
|
|
|
ASTPtr clone() const override;
|
2019-02-05 14:50:25 +00:00
|
|
|
|
2019-03-23 22:45:28 +00:00
|
|
|
void formatImpl(const FormatSettings & s, FormatState & state, FormatStateStacked frame) const override;
|
2019-02-05 14:50:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-03-23 22:45:28 +00:00
|
|
|
class ASTSelectWithUnionQuery;
|
|
|
|
|
2017-04-13 16:12:56 +00:00
|
|
|
/// CREATE TABLE or ATTACH TABLE query
|
2018-10-18 15:03:14 +00:00
|
|
|
class ASTCreateQuery : public ASTQueryWithTableAndOutput, public ASTQueryWithOnCluster
|
2011-08-18 18:48:00 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-05-27 17:27:16 +00:00
|
|
|
bool attach{false}; /// Query ATTACH TABLE, not CREATE TABLE.
|
2017-04-01 07:20:54 +00:00
|
|
|
bool if_not_exists{false};
|
|
|
|
bool is_view{false};
|
|
|
|
bool is_materialized_view{false};
|
2019-05-28 21:17:48 +00:00
|
|
|
bool is_live_view{false};
|
2017-04-01 07:20:54 +00:00
|
|
|
bool is_populate{false};
|
2019-10-08 13:26:15 +00:00
|
|
|
bool is_dictionary{false}; /// CREATE DICTIONARY
|
2019-03-11 16:50:31 +00:00
|
|
|
bool replace_view{false}; /// CREATE OR REPLACE VIEW
|
2019-02-05 14:50:25 +00:00
|
|
|
ASTColumns * columns_list = nullptr;
|
2019-10-08 13:26:15 +00:00
|
|
|
ASTExpressionList * dictionary_attributes_list = nullptr; /// attributes of dictionary
|
2019-10-01 14:54:28 +00:00
|
|
|
ASTExpressionList * tables = nullptr;
|
2017-10-30 17:53:01 +00:00
|
|
|
String to_database; /// For CREATE MATERIALIZED VIEW mv TO table.
|
|
|
|
String to_table;
|
2017-09-17 18:49:43 +00:00
|
|
|
ASTStorage * storage = nullptr;
|
2017-04-01 07:20:54 +00:00
|
|
|
String as_database;
|
|
|
|
String as_table;
|
2019-07-18 18:29:49 +00:00
|
|
|
ASTPtr as_table_function;
|
2018-02-25 06:34:20 +00:00
|
|
|
ASTSelectWithUnionQuery * select = nullptr;
|
2019-10-08 13:26:15 +00:00
|
|
|
ASTDictionary * dictionary = nullptr; /// dictionary definition (layout, primary key, etc.)
|
2017-04-01 07:20:54 +00:00
|
|
|
|
2017-05-27 17:27:16 +00:00
|
|
|
/** Get the text that identifies this element. */
|
2018-12-07 12:34:40 +00:00
|
|
|
String getID(char delim) const override { return (attach ? "AttachQuery" : "CreateQuery") + (delim + database) + delim + table; }
|
2017-04-01 07:20:54 +00:00
|
|
|
|
2019-03-23 22:45:28 +00:00
|
|
|
ASTPtr clone() const override;
|
2015-08-05 21:38:31 +00:00
|
|
|
|
2017-04-13 16:12:56 +00:00
|
|
|
ASTPtr getRewrittenASTWithoutOnCluster(const std::string & new_database) const override
|
|
|
|
{
|
2018-10-24 15:31:07 +00:00
|
|
|
return removeOnCluster<ASTCreateQuery>(clone(), new_database);
|
2017-04-13 16:12:56 +00:00
|
|
|
}
|
|
|
|
|
2015-08-05 21:38:31 +00:00
|
|
|
protected:
|
2019-03-23 22:45:28 +00:00
|
|
|
void formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
|
2011-08-18 18:48:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|