Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/Disks/ObjectStorages/IObjectStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,18 @@ std::string RelativePathWithMetadata::CommandInTaskResponse::to_string() const
return oss.str();
}


void RelativePathWithMetadata::loadMetadata(ObjectStoragePtr object_storage, bool ignore_non_existent_file)
{
if (!metadata)
{
const auto & path = isArchive() ? getPathToArchive() : getPath();

if (ignore_non_existent_file)
metadata = object_storage->tryGetObjectMetadata(path);
else
metadata = object_storage->getObjectMetadata(path);
}
}

}
2 changes: 2 additions & 0 deletions src/Disks/ObjectStorages/IObjectStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ struct RelativePathWithMetadata
std::optional<DataFileMetaInfoPtr> getFileMetaInfo() const { return file_meta_info; }

const CommandInTaskResponse & getCommand() const { return command; }

void loadMetadata(ObjectStoragePtr object_storage, bool ignore_non_existent_file = true);
};

struct ObjectKeyWithMetadata
Expand Down
3 changes: 3 additions & 0 deletions src/Interpreters/InterpreterInsertQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,9 @@ InterpreterInsertQuery::distributedWriteIntoReplicatedMergeTreeFromClusterStorag
if (!src_storage_cluster)
return {};

if (src_storage_cluster->getOriginalClusterName().empty())
return {};

if (!isInsertSelectTrivialEnoughForDistributedExecution(query))
return {};

Expand Down
12 changes: 8 additions & 4 deletions src/Storages/ObjectStorage/DataLakes/IDataLakeMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,16 @@ class KeysIterator : public IObjectIterator
return nullptr;

auto key = data_files[current_index];
auto object_metadata = object_storage->getObjectMetadata(key);

if (callback)
callback(FileProgress(0, object_metadata.size_bytes));

return std::make_shared<ObjectInfo>(key, std::move(object_metadata));
{
/// Too expencive to load size for metadata always
/// because it requires API call to external storage.
/// In many cases only keys are needed.
callback(FileProgress(0, 1));
}

return std::make_shared<ObjectInfo>(key, std::nullopt);
}
}

Expand Down
8 changes: 3 additions & 5 deletions src/Storages/ObjectStorage/ReadBufferIterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ std::optional<ColumnsDescription> ReadBufferIterator::tryGetColumnsFromCache(
const auto & object_info = (*it);
auto get_last_mod_time = [&] -> std::optional<time_t>
{
const auto & path = object_info->isArchive() ? object_info->getPathToArchive() : object_info->getPath();
if (!object_info->metadata)
object_info->metadata = object_storage->tryGetObjectMetadata(path);

object_info->loadMetadata(object_storage);
return object_info->metadata
? std::optional<time_t>(object_info->metadata->last_modified.epochTime())
: std::nullopt;
Expand Down Expand Up @@ -151,7 +148,6 @@ std::unique_ptr<ReadBuffer> ReadBufferIterator::recreateLastReadBuffer()
{
auto context = getContext();

const auto & path = current_object_info->isArchive() ? current_object_info->getPathToArchive() : current_object_info->getPath();
auto impl = createReadBuffer(*current_object_info, object_storage, context, getLogger("ReadBufferIterator"));

const auto compression_method = chooseCompressionMethod(current_object_info->getFileName(), configuration->getCompressionMethod());
Expand Down Expand Up @@ -250,6 +246,8 @@ ReadBufferIterator::Data ReadBufferIterator::next()
prev_read_keys_size = read_keys.size();
}

current_object_info->loadMetadata(object_storage);

if (query_settings.skip_empty_files
&& current_object_info->metadata && current_object_info->metadata->size_bytes == 0)
continue;
Expand Down
16 changes: 1 addition & 15 deletions src/Storages/ObjectStorage/StorageObjectStorageSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,21 +511,7 @@ StorageObjectStorageSource::ReaderHolder StorageObjectStorageSource::createReade
if (object_info->getPath().empty())
return {};

if (!object_info->metadata)
{
const auto & path = object_info->isArchive() ? object_info->getPathToArchive() : object_info->getPath();

if (query_settings.ignore_non_existent_file)
{
auto metadata = object_storage->tryGetObjectMetadata(path);
if (!metadata)
return {};

object_info->metadata = metadata;
}
else
object_info->metadata = object_storage->getObjectMetadata(path);
}
object_info->loadMetadata(object_storage, query_settings.ignore_non_existent_file);
}
while (not_a_path || (query_settings.skip_empty_files && object_info->metadata->size_bytes == 0));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env bash
# Tags: no-fasttest
# Tag no-fasttest: requires s3 storage


CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
Expand Down
Loading