2022-06-16 09:58:14 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Parsers/ASTQueryWithOnCluster.h>
|
|
|
|
#include <Parsers/ASTQueryWithTableAndOutput.h>
|
|
|
|
#include <Parsers/IAST.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2022-06-18 10:18:31 +00:00
|
|
|
/** CREATE INDEX [IF NOT EXISTS] name ON [db].name (expression) TYPE type GRANULARITY value
|
2022-06-16 09:58:14 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
class ASTCreateIndexQuery : public ASTQueryWithTableAndOutput, public ASTQueryWithOnCluster
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ASTPtr index_name;
|
|
|
|
|
2024-02-21 16:29:15 +00:00
|
|
|
/// Stores the ASTIndexDeclaration here.
|
2022-06-16 09:58:14 +00:00
|
|
|
ASTPtr index_decl;
|
|
|
|
|
2022-06-29 11:10:30 +00:00
|
|
|
bool if_not_exists{false};
|
2023-07-19 12:23:39 +00:00
|
|
|
bool unique{false};
|
2022-06-29 11:10:30 +00:00
|
|
|
|
2022-06-16 09:58:14 +00:00
|
|
|
String getID(char delim) const override;
|
|
|
|
|
|
|
|
ASTPtr clone() const override;
|
|
|
|
|
|
|
|
ASTPtr getRewrittenASTWithoutOnCluster(const WithoutOnClusterASTRewriteParams & params) const override
|
|
|
|
{
|
|
|
|
return removeOnCluster<ASTCreateIndexQuery>(clone(), params.default_database);
|
|
|
|
}
|
|
|
|
|
2022-06-29 11:10:30 +00:00
|
|
|
QueryKind getQueryKind() const override { return QueryKind::Create; }
|
|
|
|
|
|
|
|
/// Convert ASTCreateIndexQuery to ASTAlterCommand
|
|
|
|
ASTPtr convertToASTAlterCommand() const;
|
2022-06-16 09:58:14 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|