Skip to content

Commit bb156ab

Browse files
committed
some adjustments
1 parent c7003ad commit bb156ab

File tree

9 files changed

+30
-11
lines changed

9 files changed

+30
-11
lines changed

src/Access/Common/AccessType.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ enum class AccessType : uint8_t
7474
enabled implicitly by the grant ALTER_TABLE */\
7575
M(ALTER_SETTINGS, "ALTER SETTING, ALTER MODIFY SETTING, MODIFY SETTING, RESET SETTING", TABLE, ALTER_TABLE) /* allows to execute ALTER MODIFY SETTING */\
7676
M(ALTER_MOVE_PARTITION, "ALTER MOVE PART, MOVE PARTITION, MOVE PART", TABLE, ALTER_TABLE) \
77+
M(ALTER_EXPORT_PARTITION, "ALTER EXPORT PART, EXPORT PARTITION, EXPORT PART", TABLE, ALTER_TABLE) \
7778
M(ALTER_FETCH_PARTITION, "ALTER FETCH PART, FETCH PARTITION", TABLE, ALTER_TABLE) \
7879
M(ALTER_FREEZE_PARTITION, "FREEZE PARTITION, UNFREEZE", TABLE, ALTER_TABLE) \
7980
M(ALTER_UNLOCK_SNAPSHOT, "UNLOCK SNAPSHOT", TABLE, ALTER_TABLE) \

src/Interpreters/InterpreterAlterQuery.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,9 +502,9 @@ AccessRightsElements InterpreterAlterQuery::getRequiredAccessForCommand(const AS
502502
required_access.emplace_back(AccessType::ALTER_DELETE | AccessType::INSERT, database, table);
503503
break;
504504
}
505-
case ASTAlterCommand::EXPORT_PART:
505+
case ASTAlterCommand::EXPORT_PARTITION:
506506
{
507-
required_access.emplace_back(AccessType::ALTER_MOVE_PARTITION, database, table);
507+
required_access.emplace_back(AccessType::ALTER_EXPORT_PARTITION, database, table);
508508
required_access.emplace_back(AccessType::INSERT, command.to_database, command.to_table);
509509
break;
510510
}

src/Parsers/ASTAlterQuery.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ void ASTAlterCommand::formatImpl(WriteBuffer & ostr, const FormatSettings & sett
355355
ostr << quoteString(move_destination_name);
356356
}
357357
}
358-
else if (type == ASTAlterCommand::EXPORT_PART)
358+
else if (type == ASTAlterCommand::EXPORT_PARTITION)
359359
{
360360
ostr << (settings.hilite ? hilite_keyword : "") << "EXPORT " << (part ? "PART " : "PARTITION ")
361361
<< (settings.hilite ? hilite_none : "");

src/Parsers/ASTAlterQuery.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class ASTAlterCommand : public IAST
7171
FREEZE_ALL,
7272
UNFREEZE_PARTITION,
7373
UNFREEZE_ALL,
74-
EXPORT_PART,
74+
EXPORT_PARTITION,
7575

7676
DELETE,
7777
UPDATE,

src/Parsers/CommonParsers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ namespace DB
331331
MR_MACROS(MONTHS, "MONTHS") \
332332
MR_MACROS(MOVE_PART, "MOVE PART") \
333333
MR_MACROS(MOVE_PARTITION, "MOVE PARTITION") \
334+
MR_MACROS(EXPORT_PART, "EXPORT PART") \
334335
MR_MACROS(EXPORT_PARTITION, "EXPORT PARTITION") \
335336
MR_MACROS(MOVE, "MOVE") \
336337
MR_MACROS(MS, "MS") \

src/Parsers/ParserAlterQuery.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ bool ParserAlterCommand::parseImpl(Pos & pos, ASTPtr & node, Expected & expected
8282
ParserKeyword s_forget_partition(Keyword::FORGET_PARTITION);
8383
ParserKeyword s_move_partition(Keyword::MOVE_PARTITION);
8484
ParserKeyword s_move_part(Keyword::MOVE_PART);
85-
ParserKeyword s_export_part(Keyword::EXPORT_PARTITION);
85+
ParserKeyword s_export_part(Keyword::EXPORT_PART);
86+
ParserKeyword s_export_partition(Keyword::EXPORT_PARTITION);
8687
ParserKeyword s_drop_detached_partition(Keyword::DROP_DETACHED_PARTITION);
8788
ParserKeyword s_drop_detached_part(Keyword::DROP_DETACHED_PART);
8889
ParserKeyword s_fetch_partition(Keyword::FETCH_PARTITION);
@@ -565,13 +566,29 @@ bool ParserAlterCommand::parseImpl(Pos & pos, ASTPtr & node, Expected & expected
565566
command->move_destination_name = ast_space_name->as<ASTLiteral &>().value.safeGet<String>();
566567
}
567568
}
569+
else if (s_export_partition.ignore(pos, expected))
570+
{
571+
if (!parser_partition.parse(pos, command_partition, expected))
572+
return false;
573+
574+
command->type = ASTAlterCommand::EXPORT_PARTITION;
575+
576+
if (!s_to_table.ignore(pos, expected))
577+
{
578+
return false;
579+
}
580+
581+
if (!parseDatabaseAndTableName(pos, expected, command->to_database, command->to_table))
582+
return false;
583+
command->move_destination_type = DataDestinationType::TABLE;
584+
}
568585
else if (s_export_part.ignore(pos, expected))
569586
{
570587
if (!parser_partition.parse(pos, command_partition, expected))
571588
return false;
572589

573-
command->type = ASTAlterCommand::EXPORT_PART;
574-
// command->part = true;
590+
command->type = ASTAlterCommand::EXPORT_PARTITION;
591+
command->part = true;
575592

576593
if (!s_to_table.ignore(pos, expected))
577594
{

src/Storages/MergeTree/MergeTreeData.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5940,7 +5940,7 @@ Pipe MergeTreeData::alterPartition(
59405940
}
59415941
}
59425942
break;
5943-
case PartitionCommand::EXPORT_PART:
5943+
case PartitionCommand::EXPORT_PARTITION:
59445944
{
59455945
exportPartitionToTable(command, query_context);
59465946
break;

src/Storages/PartitionCommands.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ std::optional<PartitionCommand> PartitionCommand::parse(const ASTAlterCommand *
5252
res.part = command_ast->part;
5353
return res;
5454
}
55-
if (command_ast->type == ASTAlterCommand::EXPORT_PART)
55+
if (command_ast->type == ASTAlterCommand::EXPORT_PARTITION)
5656
{
5757
PartitionCommand res;
58-
res.type = EXPORT_PART;
58+
res.type = EXPORT_PARTITION;
5959
res.partition = command_ast->partition->clone();
6060
res.part = command_ast->part;
6161
res.move_destination_type = PartitionCommand::MoveDestinationType::TABLE;

src/Storages/PartitionCommands.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct PartitionCommand
3333
UNFREEZE_ALL_PARTITIONS,
3434
UNFREEZE_PARTITION,
3535
REPLACE_PARTITION,
36-
EXPORT_PART,
36+
EXPORT_PARTITION,
3737
};
3838

3939
Type type = UNKNOWN;

0 commit comments

Comments
 (0)