diff --git a/dbms/src/Interpreters/InterpreterFactory.cpp b/dbms/src/Interpreters/InterpreterFactory.cpp index cc975e62dbf..54611860227 100644 --- a/dbms/src/Interpreters/InterpreterFactory.cpp +++ b/dbms/src/Interpreters/InterpreterFactory.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include @@ -26,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -115,10 +113,6 @@ std::unique_ptr InterpreterFactory::get(ASTPtr & query, Context & throwIfNoAccess(context); return std::make_unique(query, context); } - else if (query->as()) - { - return std::make_unique(query, context); - } else if (query->as()) { return std::make_unique(query, context); diff --git a/dbms/src/Interpreters/InterpreterMoveQuery.cpp b/dbms/src/Interpreters/InterpreterMoveQuery.cpp deleted file mode 100644 index 2b6f2753379..00000000000 --- a/dbms/src/Interpreters/InterpreterMoveQuery.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - - -namespace DB -{ - - -InterpreterMoveQuery::InterpreterMoveQuery(const ASTPtr & query_ptr_, const Context & context_) - : query_ptr(query_ptr_), context(context_) -{ -} - - -BlockIO InterpreterMoveQuery::execute() -{ - const auto & move = query_ptr->as(); - - if (!move.cluster.empty()) - { - ///@TODO_IGR ASK WHAT SHOULD I DO HERE -// NameSet databases; -// for (const auto & elem : rename.elements) -// { -// databases.emplace(elem.from.database); -// databases.emplace(elem.to.database); -// } -// -// return executeDDLQueryOnCluster(query_ptr, context, std::move(databases)); - } - - String path = context.getPath(); - String current_database = context.getCurrentDatabase(); - - auto table = context.tryGetTable(move.table.database, move.table.table); -// if (!table) ///@TODO_IGR - - TableStructureWriteLockHolder table_lock(table->lockExclusively(context.getCurrentQueryId())); - - decltype(context.getLock()) lock; - - lock = context.getLock(); - - table->move(move.part_name, move.destination_disk_name); - - return {}; -} - - -} diff --git a/dbms/src/Interpreters/InterpreterMoveQuery.h b/dbms/src/Interpreters/InterpreterMoveQuery.h deleted file mode 100644 index 4b4f7408c6e..00000000000 --- a/dbms/src/Interpreters/InterpreterMoveQuery.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#include -#include - - -namespace DB -{ - -class Context; - -/** Allows you a in the table. - */ -class InterpreterMoveQuery : public IInterpreter -{ -public: - InterpreterMoveQuery(const ASTPtr & query_ptr_, const Context & context_); - - BlockIO execute() override; - -private: - ASTPtr query_ptr; - - const Context & context; -}; - -} diff --git a/dbms/src/Parsers/ASTAlterQuery.cpp b/dbms/src/Parsers/ASTAlterQuery.cpp index ccd45c94a3b..b99170def5c 100644 --- a/dbms/src/Parsers/ASTAlterQuery.cpp +++ b/dbms/src/Parsers/ASTAlterQuery.cpp @@ -130,19 +130,18 @@ void ASTAlterCommand::formatImpl( << (part ? "PART " : "PARTITION ") << (settings.hilite ? hilite_none : ""); partition->formatImpl(settings, state, frame); settings.ostr << "TO "; - switch (space_to_move) + switch (move_destination_type) { - case SpaceToMove::DISK: + case MoveDestinationType::DISK: settings.ostr << "DISK "; break; - case SpaceToMove::VOLUME: + case MoveDestinationType::VOLUME: settings.ostr << "VOLUME "; break; - case SpaceToMove::NONE: - default: - break; + case MoveDestinationType::NONE: + throw Exception("Unexpected MOVE destination (NONE)", ErrorCodes::UNEXPECTED_AST_STRUCTURE); } - settings.ostr << space_to_move_name; + settings.ostr << move_destination_name; } else if (type == ASTAlterCommand::REPLACE_PARTITION) { diff --git a/dbms/src/Parsers/ASTAlterQuery.h b/dbms/src/Parsers/ASTAlterQuery.h index a29be885b6f..506fc146423 100644 --- a/dbms/src/Parsers/ASTAlterQuery.h +++ b/dbms/src/Parsers/ASTAlterQuery.h @@ -99,16 +99,16 @@ public: bool if_exists = false; /// option for DROP_COLUMN, MODIFY_COLUMN, COMMENT_COLUMN - enum SpaceToMove + enum MoveDestinationType { DISK, VOLUME, NONE, }; - SpaceToMove space_to_move = SpaceToMove::NONE; + MoveDestinationType move_destination_type = MoveDestinationType::NONE; - String space_to_move_name; + String move_destination_name; /** For FETCH PARTITION - the path in ZK to the shard, from which to download the partition. */ diff --git a/dbms/src/Parsers/ASTMoveQuery.h b/dbms/src/Parsers/ASTMoveQuery.h deleted file mode 100644 index 06125df5e62..00000000000 --- a/dbms/src/Parsers/ASTMoveQuery.h +++ /dev/null @@ -1,64 +0,0 @@ -#pragma once - -#include -#include -#include - -namespace DB -{ - - -/** MOVE query - */ -class ASTMoveQuery : public ASTQueryWithOutput, public ASTQueryWithOnCluster -{ -public: - struct Table - { - String database; - String table; - }; - - Table table; - String part_name; - String destination_disk_name; - - /** Get the text that identifies this element. */ - String getID(char) const override { return "Move"; } - - ASTPtr clone() const override - { - auto res = std::make_shared(*this); - cloneOutputOptions(*res); - return res; - } - - ASTPtr getRewrittenASTWithoutOnCluster(const std::string & /*new_database*/) const override - { - ///@TODO_IGR ASK - auto query_ptr = clone(); - auto & query = query_ptr->as(); - - query.cluster.clear(); - - query.table = table; - query.part_name = part_name; - query.destination_disk_name = destination_disk_name; - - return query_ptr; - } - -protected: - void formatQueryImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override - { - settings.ostr << (settings.hilite ? hilite_keyword : "") << "TABLE" - << (settings.hilite ? hilite_keyword : "") - << (table.database.empty() ? backQuoteIfNeed(table.database) + "." : "") << backQuoteIfNeed(table.table) - << (settings.hilite ? hilite_keyword : "") << "MOVE PART" - << (settings.hilite ? hilite_keyword : "") << part_name - << (settings.hilite ? hilite_keyword : "") << "TO" - << (settings.hilite ? hilite_none : "") << destination_disk_name; - } -}; - -} diff --git a/dbms/src/Parsers/ParserAlterQuery.cpp b/dbms/src/Parsers/ParserAlterQuery.cpp index 8b3e5bdee76..62b31311241 100644 --- a/dbms/src/Parsers/ParserAlterQuery.cpp +++ b/dbms/src/Parsers/ParserAlterQuery.cpp @@ -203,9 +203,9 @@ bool ParserAlterCommand::parseImpl(Pos & pos, ASTPtr & node, Expected & expected command->type = ASTAlterCommand::MOVE_PARTITION; if (s_to_disk.ignore(pos)) - command->space_to_move = ASTAlterCommand::SpaceToMove::DISK; + command->move_destination_type = ASTAlterCommand::MoveDestinationType::DISK; else if (s_to_volume.ignore(pos)) - command->space_to_move = ASTAlterCommand::SpaceToMove::VOLUME; + command->move_destination_type = ASTAlterCommand::MoveDestinationType::VOLUME; else return false; @@ -213,7 +213,7 @@ bool ParserAlterCommand::parseImpl(Pos & pos, ASTPtr & node, Expected & expected if (!parser_string_literal.parse(pos, ast_space_name, expected)) return false; - command->space_to_move_name = ast_space_name->as().value.get(); + command->move_destination_name = ast_space_name->as().value.get(); } else if (s_fetch_partition.ignore(pos, expected)) { diff --git a/dbms/src/Parsers/ParserMoveQuery.cpp b/dbms/src/Parsers/ParserMoveQuery.cpp deleted file mode 100644 index 477baeb3cec..00000000000 --- a/dbms/src/Parsers/ParserMoveQuery.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include -#include - -#include -#include - - -namespace DB -{ - - -/// Parse database.table or table. -static bool parseDatabaseAndTable( - ASTMoveQuery::Table & db_and_table, IParser::Pos & pos, Expected & expected) -{ - ParserIdentifier name_p; - ParserToken s_dot(TokenType::Dot); - - ASTPtr database; - ASTPtr table; - - if (!name_p.parse(pos, table, expected)) - return false; - - if (s_dot.ignore(pos, expected)) - { - database = table; - if (!name_p.parse(pos, table, expected)) - return false; - } - - db_and_table.database.clear(); - getIdentifierName(database, db_and_table.database); - getIdentifierName(table, db_and_table.table); - - return true; -} - - -bool ParserMoveQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected) -{ - ParserIdentifier name_p; - ParserKeyword s_table("TABLE"); - ParserKeyword s_move_part("MOVE PART"); - ParserKeyword s_to("TO"); - ParserToken s_comma(TokenType::Comma); - - if (!s_table.ignore(pos, expected)) - return false; - - ASTMoveQuery::Table table; - - if (!parseDatabaseAndTable(table, pos, expected)) - return false; - - if (!s_move_part.ignore(pos, expected)) - return false; - - String part_name; - String destination_disk_name; - - ASTPtr part_name_ast_ptr; - ASTPtr destination_disk_name_ast_ptr; - - if (!name_p.parse(pos, part_name_ast_ptr, expected)) - return false; - - if (!s_to.ignore(pos, expected)) - return false; - - if (!name_p.parse(pos, destination_disk_name_ast_ptr, expected)) - return false; - - - getIdentifierName(part_name_ast_ptr, part_name); - getIdentifierName(destination_disk_name_ast_ptr, destination_disk_name); - - String cluster_str; - if (ParserKeyword{"ON"}.ignore(pos, expected)) - { - if (!ASTQueryWithOnCluster::parse(pos, cluster_str, expected)) - return false; - } - - auto query = std::make_shared(); - query->cluster = cluster_str; - node = query; - - query->table = table; - query->part_name = part_name; - query->destination_disk_name = destination_disk_name; - return true; -} - - -} diff --git a/dbms/src/Parsers/ParserMoveQuery.h b/dbms/src/Parsers/ParserMoveQuery.h deleted file mode 100644 index 4d3cab55f91..00000000000 --- a/dbms/src/Parsers/ParserMoveQuery.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include -#include - - -namespace DB -{ - -/** Query like this: - * RENAME TABLE [db.]name TO [db.]name, [db.]name TO [db.]name, ... - * (An arbitrary number of tables can be renamed.) - */ -class ParserMoveQuery : public IParserBase -{ -protected: - const char * getName() const { return "MOVE query"; } - bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected); -}; - -} diff --git a/dbms/src/Parsers/ParserQueryWithOutput.cpp b/dbms/src/Parsers/ParserQueryWithOutput.cpp index 4be9f28337a..c41e0946a96 100644 --- a/dbms/src/Parsers/ParserQueryWithOutput.cpp +++ b/dbms/src/Parsers/ParserQueryWithOutput.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -33,7 +32,6 @@ bool ParserQueryWithOutput::parseImpl(Pos & pos, ASTPtr & node, Expected & expec ParserCheckQuery check_p; ParserOptimizeQuery optimize_p; ParserKillQueryQuery kill_query_p; - ParserMoveQuery move_p; ASTPtr query; @@ -59,8 +57,7 @@ bool ParserQueryWithOutput::parseImpl(Pos & pos, ASTPtr & node, Expected & expec || drop_p.parse(pos, query, expected) || check_p.parse(pos, query, expected) || kill_query_p.parse(pos, query, expected) - || optimize_p.parse(pos, query, expected) - || move_p.parse(pos, query, expected); + || optimize_p.parse(pos, query, expected); if (!parsed) return false; diff --git a/dbms/src/Storages/PartitionCommands.cpp b/dbms/src/Storages/PartitionCommands.cpp index 1e6ce69d352..a920411554d 100644 --- a/dbms/src/Storages/PartitionCommands.cpp +++ b/dbms/src/Storages/PartitionCommands.cpp @@ -37,19 +37,19 @@ std::optional PartitionCommand::parse(const ASTAlterCommand * res.type = MOVE_PARTITION; res.partition = command_ast->partition; res.part = command_ast->part; - switch (command_ast->space_to_move) + switch (command_ast->move_destination_type) { - case ASTAlterCommand::SpaceToMove::DISK: + case ASTAlterCommand::MoveDestinationType::DISK: res.space_to_move = PartitionCommand::SpaceToMove::DISK; break; - case ASTAlterCommand::SpaceToMove::VOLUME: + case ASTAlterCommand::MoveDestinationType::VOLUME: res.space_to_move = PartitionCommand::SpaceToMove::VOLUME; break; - case ASTAlterCommand::SpaceToMove::NONE: + case ASTAlterCommand::MoveDestinationType::NONE: res.space_to_move = PartitionCommand::SpaceToMove::NONE; break; } - res.space_to_move_name = command_ast->space_to_move_name; + res.space_to_move_name = command_ast->move_destination_name; return res; } else if (command_ast->type == ASTAlterCommand::REPLACE_PARTITION)