@@ -129,17 +129,25 @@ std::shared_ptr<IObjectIterator> StorageObjectStorageSource::createFileIterator(
129129 const ActionsDAG::Node * predicate,
130130 const NamesAndTypesList & virtual_columns,
131131 ObjectInfos * read_keys,
132- std::function<void (FileProgress)> file_progress_callback)
132+ std::function<void (FileProgress)> file_progress_callback,
133+ bool ignore_archive_globs)
133134{
135+ const bool is_archive = configuration->isArchive ();
136+
134137 if (distributed_processing)
135- return std::make_shared<ReadTaskIterator>(local_context->getReadTaskCallback (), local_context->getSettingsRef ()[Setting::max_threads]);
138+ {
139+ auto distributed_iterator = std::make_unique<ReadTaskIterator>(local_context->getReadTaskCallback (), local_context->getSettingsRef ()[Setting::max_threads]);
140+
141+ if (is_archive)
142+ return std::make_shared<ArchiveIterator>(object_storage, configuration, std::move (distributed_iterator), local_context, nullptr );
143+
144+ return distributed_iterator;
145+ }
136146
137147 if (configuration->isNamespaceWithGlobs ())
138148 throw Exception (ErrorCodes::BAD_ARGUMENTS,
139149 " Expression can not have wildcards inside {} name" , configuration->getNamespaceType ());
140150
141- const bool is_archive = configuration->isArchive ();
142-
143151 std::unique_ptr<IObjectIterator> iterator;
144152 if (configuration->isPathWithGlobs ())
145153 {
@@ -190,7 +198,7 @@ std::shared_ptr<IObjectIterator> StorageObjectStorageSource::createFileIterator(
190198
191199 if (is_archive)
192200 {
193- return std::make_shared<ArchiveIterator>(object_storage, configuration, std::move (iterator), local_context, read_keys);
201+ return std::make_shared<ArchiveIterator>(object_storage, configuration, std::move (iterator), local_context, read_keys, ignore_archive_globs );
194202 }
195203
196204 return iterator;
@@ -539,9 +547,8 @@ std::unique_ptr<ReadBufferFromFileBase> StorageObjectStorageSource::createReadBu
539547 if (!object_info.metadata )
540548 {
541549 if (!use_cache)
542- {
543550 return object_storage->readObject (StoredObject (object_info.getPath ()), read_settings);
544- }
551+
545552 object_info.metadata = object_storage->getObjectMetadata (object_info.getPath ());
546553 }
547554
@@ -646,6 +653,7 @@ std::unique_ptr<ReadBufferFromFileBase> StorageObjectStorageSource::createReadBu
646653 impl->setReadUntilEnd ();
647654 impl->prefetch (DEFAULT_PREFETCH_PRIORITY);
648655 }
656+
649657 return impl;
650658}
651659
@@ -828,7 +836,7 @@ StorageObjectStorage::ObjectInfoPtr StorageObjectStorageSource::KeysIterator::ne
828836 {
829837 size_t current_index = index.fetch_add (1 , std::memory_order_relaxed);
830838 if (current_index >= keys.size ())
831- return {} ;
839+ return nullptr ;
832840
833841 auto key = keys[current_index];
834842
@@ -898,16 +906,24 @@ StorageObjectStorageSource::ReadTaskIterator::ReadTaskIterator(
898906 for (auto & key_future : keys)
899907 {
900908 auto key = key_future.get ();
901- if (!key.empty ())
902- buffer.emplace_back (std::make_shared<ObjectInfo>(key, std::nullopt ));
909+ if (key.empty ())
910+ continue ;
911+
912+ buffer.emplace_back (std::make_shared<ObjectInfo>(key, std::nullopt ));
903913 }
904914}
905915
906916StorageObjectStorage::ObjectInfoPtr StorageObjectStorageSource::ReadTaskIterator::next (size_t )
907917{
908918 size_t current_index = index.fetch_add (1 , std::memory_order_relaxed);
909919 if (current_index >= buffer.size ())
910- return std::make_shared<ObjectInfo>(callback ());
920+ {
921+ auto key = callback ();
922+ if (key.empty ())
923+ return nullptr ;
924+
925+ return std::make_shared<ObjectInfo>(key, std::nullopt );
926+ }
911927
912928 return buffer[current_index];
913929}
@@ -938,7 +954,8 @@ StorageObjectStorageSource::ArchiveIterator::ArchiveIterator(
938954 ConfigurationPtr configuration_,
939955 std::unique_ptr<IObjectIterator> archives_iterator_,
940956 ContextPtr context_,
941- ObjectInfos * read_keys_)
957+ ObjectInfos * read_keys_,
958+ bool ignore_archive_globs_)
942959 : WithContext(context_)
943960 , object_storage(object_storage_)
944961 , is_path_in_archive_with_globs(configuration_->isPathInArchiveWithGlobs ())
@@ -947,6 +964,7 @@ StorageObjectStorageSource::ArchiveIterator::ArchiveIterator(
947964 , log(getLogger(" ArchiveIterator" ))
948965 , path_in_archive(is_path_in_archive_with_globs ? " " : configuration_->getPathInArchive ())
949966 , read_keys(read_keys_)
967+ , ignore_archive_globs(ignore_archive_globs_)
950968{
951969}
952970
@@ -977,12 +995,15 @@ ObjectInfoPtr StorageObjectStorageSource::ArchiveIterator::next(size_t processor
977995 if (!archive_object)
978996 return {};
979997
998+ if (!archive_object->metadata )
999+ archive_object->metadata = object_storage->getObjectMetadata (archive_object->getPath ());
1000+
9801001 archive_reader = createArchiveReader (archive_object);
9811002 file_enumerator = archive_reader->firstFile ();
9821003 if (!file_enumerator)
9831004 continue ;
9841005 }
985- else if (!file_enumerator->nextFile ())
1006+ else if (!file_enumerator->nextFile () || ignore_archive_globs )
9861007 {
9871008 file_enumerator.reset ();
9881009 continue ;
0 commit comments