Skip to content

Commit 9c0be2e

Browse files
committed
squash export mt part to obj storage
1 parent e00145a commit 9c0be2e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1397
-56
lines changed

src/Common/CurrentMetrics.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
M(Merge, "Number of executing background merges") \
1111
M(MergeParts, "Number of source parts participating in current background merges") \
1212
M(Move, "Number of currently executing moves") \
13+
M(Export, "Number of currently executing exports") \
1314
M(PartMutation, "Number of mutations (ALTER DELETE/UPDATE)") \
1415
M(ReplicatedFetch, "Number of data parts being fetched from replica") \
1516
M(ReplicatedSend, "Number of data parts being sent to replicas") \

src/Databases/DatabaseS3.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <Storages/IStorage.h>
2020
#include <Storages/NamedCollectionsHelpers.h>
2121
#include <TableFunctions/TableFunctionFactory.h>
22+
#include <Parsers/ASTInsertQuery.h>
2223

2324
#include <boost/algorithm/string.hpp>
2425
#include <filesystem>

src/Disks/ObjectStorages/IObjectStorage.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ struct RelativePathWithMetadata
9696
virtual ~RelativePathWithMetadata() = default;
9797

9898
virtual std::string getFileName() const { return std::filesystem::path(relative_path).filename(); }
99+
virtual std::string getFileNameWithoutExtension() const { return std::filesystem::path(relative_path).stem(); }
99100
virtual std::string getPath() const { return relative_path; }
100101
virtual bool isArchive() const { return false; }
101102
virtual std::string getPathToArchive() const { throw Exception(ErrorCodes::LOGICAL_ERROR, "Not an archive"); }

src/Interpreters/Context.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ struct ContextSharedPart : boost::noncopyable
463463
GlobalOvercommitTracker global_overcommit_tracker;
464464
MergeList merge_list; /// The list of executable merge (for (Replicated)?MergeTree)
465465
MovesList moves_list; /// The list of executing moves (for (Replicated)?MergeTree)
466+
ExportsList exports_list; /// The list of executing exports MergeTree -> Object storage
466467
ReplicatedFetchList replicated_fetch_list;
467468
RefreshSet refresh_set; /// The list of active refreshes (for MaterializedView)
468469
ConfigurationPtr users_config TSA_GUARDED_BY(mutex); /// Config with the users, profiles and quotas sections.
@@ -1148,6 +1149,8 @@ MergeList & Context::getMergeList() { return shared->merge_list; }
11481149
const MergeList & Context::getMergeList() const { return shared->merge_list; }
11491150
MovesList & Context::getMovesList() { return shared->moves_list; }
11501151
const MovesList & Context::getMovesList() const { return shared->moves_list; }
1152+
ExportsList & Context::getExportsList() { return shared->exports_list; }
1153+
const ExportsList & Context::getExportsList() const { return shared->exports_list; }
11511154
ReplicatedFetchList & Context::getReplicatedFetchList() { return shared->replicated_fetch_list; }
11521155
const ReplicatedFetchList & Context::getReplicatedFetchList() const { return shared->replicated_fetch_list; }
11531156
RefreshSet & Context::getRefreshSet() { return shared->refresh_set; }

src/Interpreters/Context.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#include <mutex>
3333
#include <optional>
3434

35+
#include "Storages/ExportsList.h"
36+
3537

3638
namespace Poco::Net
3739
{
@@ -1141,6 +1143,9 @@ class Context: public ContextData, public std::enable_shared_from_this<Context>
11411143
MovesList & getMovesList();
11421144
const MovesList & getMovesList() const;
11431145

1146+
ExportsList & getExportsList();
1147+
const ExportsList & getExportsList() const;
1148+
11441149
ReplicatedFetchList & getReplicatedFetchList();
11451150
const ReplicatedFetchList & getReplicatedFetchList() const;
11461151

src/Interpreters/InterpreterAlterQuery.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,12 @@ 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:
506+
{
507+
required_access.emplace_back(AccessType::ALTER_MOVE_PARTITION, database, table);
508+
required_access.emplace_back(AccessType::INSERT, command.to_database, command.to_table);
509+
break;
510+
}
505511
case ASTAlterCommand::FETCH_PARTITION:
506512
{
507513
required_access.emplace_back(AccessType::ALTER_FETCH_PARTITION, database, table);

src/Interpreters/PartLog.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ ColumnsDescription PartLogElement::getColumnsDescription()
6969
{"MovePart", static_cast<Int8>(MOVE_PART)},
7070
{"MergePartsStart", static_cast<Int8>(MERGE_PARTS_START)},
7171
{"MutatePartStart", static_cast<Int8>(MUTATE_PART_START)},
72+
{"ExportPart", static_cast<Int8>(EXPORT_PART)},
7273
}
7374
);
7475

@@ -109,7 +110,8 @@ ColumnsDescription PartLogElement::getColumnsDescription()
109110
"RemovePart — Removing or detaching a data part using [DETACH PARTITION](/sql-reference/statements/alter/partition#detach-partitionpart)."
110111
"MutatePartStart — Mutating of a data part has started, "
111112
"MutatePart — Mutating of a data part has finished, "
112-
"MovePart — Moving the data part from the one disk to another one."},
113+
"MovePart — Moving the data part from the one disk to another one."
114+
"ExportPart — Exporting the data part from a merge tree table to one (e.g, object storage)."},
113115
{"merge_reason", std::move(merge_reason_datatype),
114116
"The reason for the event with type MERGE_PARTS. Can have one of the following values: "
115117
"NotAMerge — The current event has the type other than MERGE_PARTS, "

src/Interpreters/PartLog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ struct PartLogElement
3030
MOVE_PART = 6,
3131
MERGE_PARTS_START = 7,
3232
MUTATE_PART_START = 8,
33+
EXPORT_PART = 9,
3334
};
3435

3536
/// Copy of MergeAlgorithm since values are written to disk.

src/Parsers/ASTAlterQuery.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,29 @@ void ASTAlterCommand::formatImpl(WriteBuffer & ostr, const FormatSettings & sett
355355
ostr << quoteString(move_destination_name);
356356
}
357357
}
358+
else if (type == ASTAlterCommand::EXPORT_PART)
359+
{
360+
ostr << (settings.hilite ? hilite_keyword : "") << "EXPORT " << (part ? "PART " : "PARTITION ")
361+
<< (settings.hilite ? hilite_none : "");
362+
partition->format(ostr, settings, state, frame);
363+
ostr << " TO ";
364+
switch (move_destination_type)
365+
{
366+
case DataDestinationType::TABLE:
367+
ostr << "TABLE ";
368+
if (!to_database.empty())
369+
{
370+
ostr << (settings.hilite ? hilite_identifier : "") << backQuoteIfNeed(to_database)
371+
<< (settings.hilite ? hilite_none : "") << ".";
372+
}
373+
ostr << (settings.hilite ? hilite_identifier : "") << backQuoteIfNeed(to_table)
374+
<< (settings.hilite ? hilite_none : "");
375+
return;
376+
default:
377+
break;
378+
}
379+
380+
}
358381
else if (type == ASTAlterCommand::REPLACE_PARTITION)
359382
{
360383
ostr << (settings.hilite ? hilite_keyword : "") << (replace ? "REPLACE" : "ATTACH") << " PARTITION "

src/Parsers/ASTAlterQuery.h

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

7576
DELETE,
7677
UPDATE,

0 commit comments

Comments
 (0)