Skip to content

Commit ea3a2a5

Browse files
committed
rewind the part names logic
1 parent b02789e commit ea3a2a5

File tree

4 files changed

+8
-49
lines changed

4 files changed

+8
-49
lines changed

src/Storages/ObjectStorage/FilePathGenerator.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ namespace DB
1010
struct ObjectStorageFilePathGenerator
1111
{
1212
virtual ~ObjectStorageFilePathGenerator() = default;
13-
virtual std::string getWritingPath(const std::string & partition_id, std::optional<std::string> filename_override = {}) const = 0;
13+
virtual std::string getWritingPath(const std::string & partition_id) const = 0;
1414
virtual std::string getReadingPath() const = 0;
1515
};
1616

1717
struct ObjectStorageWildcardFilePathGenerator : ObjectStorageFilePathGenerator
1818
{
1919
explicit ObjectStorageWildcardFilePathGenerator(const std::string & raw_path_) : raw_path(raw_path_) {}
2020

21-
std::string getWritingPath(const std::string & partition_id, std::optional<std::string> /**/ = {}) const override
21+
std::string getWritingPath(const std::string & partition_id) const override
2222
{
2323
return PartitionedSink::replaceWildcards(raw_path, partition_id);
2424
}
@@ -41,9 +41,9 @@ namespace DB
4141
const std::shared_ptr<ObjectStorageFilenameGenerator> & filename_generator_)
4242
: raw_path(raw_path_), file_format(Poco::toLower(file_format_)), filename_generator(filename_generator_){}
4343

44-
std::string getWritingPath(const std::string & partition_id, std::optional<std::string> filename_override) const override
44+
std::string getWritingPath(const std::string & partition_id) const override
4545
{
46-
return raw_path + "/" + partition_id + "/" + (filename_override ? *filename_override : filename_generator->generate()) + "." + file_format;
46+
return raw_path + "/" + partition_id + "/" + filename_generator->generate() + "." + file_format;
4747
}
4848

4949
std::string getReadingPath() const override

src/Storages/ObjectStorage/StorageObjectStorage.cpp

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,6 @@ void StorageObjectStorage::importMergeTreePartition(
554554
if (data_parts.empty())
555555
return;
556556

557-
RelativePathsWithMetadata relative_paths_with_metadata;
558-
object_storage->listObjects(configuration->getRawPath().path, relative_paths_with_metadata, 1000);
559-
560557
std::vector<QueryPlanPtr> part_plans;
561558
part_plans.reserve(data_parts.size());
562559

@@ -580,44 +577,13 @@ void StorageObjectStorage::importMergeTreePartition(
580577
std::vector<StoredObject> files_to_be_deleted;
581578
for (const auto & data_part : data_parts)
582579
{
583-
bool upload_part = true;
584-
for (const auto & object_with_metadata : relative_paths_with_metadata)
585-
{
586-
const auto remote_object_filename = object_with_metadata->getFileNameWithoutExtension();
587-
if (remote_object_filename == data_part->name)
588-
{
589-
upload_part = false;
590-
break;
591-
}
592-
593-
const auto remote_fake_part = MergeTreePartInfo::tryParsePartName(remote_object_filename, merge_tree_data.format_version);
594-
595-
if (!remote_fake_part)
596-
{
597-
continue;
598-
}
599-
600-
/// If the part does not intersect, proceed to the next file
601-
if (data_part->info.isDisjoint(remote_fake_part.value()))
602-
{
603-
continue;
604-
}
605-
606-
files_to_be_deleted.emplace_back(object_with_metadata->relative_path);
607-
}
608-
609-
if (!upload_part)
610-
{
611-
continue;
612-
}
613-
614580
const auto partition_columns = configuration->partition_strategy->getPartitionColumns();
615581

616582
auto block_with_partition_values = data_part->partition.getBlockWithPartitionValues(partition_columns);
617583

618584
const auto column_with_partition_key = configuration->partition_strategy->computePartitionKey(block_with_partition_values);
619585

620-
const auto file_path = configuration->file_path_generator->getWritingPath(column_with_partition_key->getDataAt(0).toString(), data_part->name);
586+
const auto file_path = configuration->file_path_generator->getWritingPath(column_with_partition_key->getDataAt(0).toString());
621587

622588
export_list_entries.emplace_back(local_context->getGlobalContext()->getExportsList().insert(
623589
merge_tree_data.getStorageID(),
@@ -683,9 +649,6 @@ void StorageObjectStorage::importMergeTreePartition(
683649
{
684650
root_pipeline.setNumThreads(local_context->getSettingsRef()[Setting::max_threads]);
685651

686-
/// shouldn't this be part of the sink and or pipeline?
687-
object_storage->removeObjectsIfExist(files_to_be_deleted);
688-
689652
CompletedPipelineExecutor exec(root_pipeline);
690653
exec.execute();
691654
}

src/Storages/ObjectStorage/StorageObjectStorageSink.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,14 @@ PartitionedStorageObjectStorageSink::PartitionedStorageObjectStorageSink(
133133
const std::shared_ptr<ObjectStorageFilePathGenerator> & file_path_generator_,
134134
std::optional<FormatSettings> format_settings_,
135135
const Block & sample_block_,
136-
ContextPtr context_,
137-
std::optional<std::string> filename_override_)
136+
ContextPtr context_)
138137
: object_storage(object_storage_)
139138
, configuration(configuration_)
140139
, file_path_generator(file_path_generator_)
141140
, query_settings(configuration_->getQuerySettings(context_))
142141
, format_settings(format_settings_)
143142
, sample_block(sample_block_)
144143
, context(context_)
145-
, filename_override(filename_override_)
146144
{
147145
}
148146

@@ -154,7 +152,7 @@ StorageObjectStorageSink::~StorageObjectStorageSink()
154152

155153
SinkPtr PartitionedStorageObjectStorageSink::createSinkForPartition(const String & partition_id)
156154
{
157-
auto file_path = file_path_generator->getWritingPath(partition_id, filename_override);
155+
auto file_path = file_path_generator->getWritingPath(partition_id);
158156

159157
validateNamespace(configuration->getNamespace(), configuration);
160158
validateKey(file_path);

src/Storages/ObjectStorage/StorageObjectStorageSink.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ class PartitionedStorageObjectStorageSink : public PartitionedSink::SinkCreator
5050
const std::shared_ptr<ObjectStorageFilePathGenerator> & file_path_generator_,
5151
std::optional<FormatSettings> format_settings_,
5252
const Block & sample_block_,
53-
ContextPtr context_,
54-
std::optional<std::string> filename_override_ = std::nullopt);
53+
ContextPtr context_);
5554

5655
SinkPtr createSinkForPartition(const String & partition_id) override;
5756

@@ -64,7 +63,6 @@ class PartitionedStorageObjectStorageSink : public PartitionedSink::SinkCreator
6463
const std::optional<FormatSettings> format_settings;
6564
const Block sample_block;
6665
const ContextPtr context;
67-
std::optional<std::string> filename_override;
6866
};
6967

7068
}

0 commit comments

Comments
 (0)