diff --git a/src/Storages/ObjectStorage/StorageObjectStorage.cpp b/src/Storages/ObjectStorage/StorageObjectStorage.cpp index 5e9ce8dce28..591e085276c 100644 --- a/src/Storages/ObjectStorage/StorageObjectStorage.cpp +++ b/src/Storages/ObjectStorage/StorageObjectStorage.cpp @@ -42,7 +42,7 @@ namespace ErrorCodes extern const int LOGICAL_ERROR; } -String StorageObjectStorage::getPathSample(StorageInMemoryMetadata metadata, ContextPtr context) +String StorageObjectStorage::getPathSample(ContextPtr context) { auto query_settings = configuration->getQuerySettings(context); /// We don't want to throw an exception if there are no files with specified path. @@ -60,7 +60,7 @@ String StorageObjectStorage::getPathSample(StorageInMemoryMetadata metadata, Con local_distributed_processing, context, {}, // predicate - metadata.getColumns().getAll(), // virtual_columns + {}, // virtual_columns nullptr, // read_keys {} // file_progress_callback ); @@ -121,7 +121,7 @@ StorageObjectStorage::StorageObjectStorage( metadata.setComment(comment); if (sample_path.empty() && context->getSettingsRef()[Setting::use_hive_partitioning]) - sample_path = getPathSample(metadata, context); + sample_path = getPathSample(context); setVirtuals(VirtualColumnUtils::getVirtualsForFileLikeStorage(metadata.columns, context, sample_path, format_settings)); setInMemoryMetadata(metadata); diff --git a/src/Storages/ObjectStorage/StorageObjectStorage.h b/src/Storages/ObjectStorage/StorageObjectStorage.h index e2bb41a4935..b1dca777466 100644 --- a/src/Storages/ObjectStorage/StorageObjectStorage.h +++ b/src/Storages/ObjectStorage/StorageObjectStorage.h @@ -123,7 +123,7 @@ public: const ContextPtr & context); protected: - String getPathSample(StorageInMemoryMetadata metadata, ContextPtr context); + String getPathSample(ContextPtr context); static std::unique_ptr createReadBufferIterator( const ObjectStoragePtr & object_storage, diff --git a/src/Storages/ObjectStorage/StorageObjectStorageSource.cpp b/src/Storages/ObjectStorage/StorageObjectStorageSource.cpp index 60a22d72cd9..2f50a59db9a 100644 --- a/src/Storages/ObjectStorage/StorageObjectStorageSource.cpp +++ b/src/Storages/ObjectStorage/StorageObjectStorageSource.cpp @@ -757,6 +757,7 @@ StorageObjectStorage::ObjectInfoPtr StorageObjectStorageSource::KeysIterator::ne auto metadata = object_storage->tryGetObjectMetadata(key); if (!metadata) continue; + object_metadata = *metadata; } else object_metadata = object_storage->getObjectMetadata(key); diff --git a/tests/queries/0_stateless/03275_ignore_nonexistent_files_fix.reference b/tests/queries/0_stateless/03275_ignore_nonexistent_files_fix.reference new file mode 100644 index 00000000000..c6650297703 --- /dev/null +++ b/tests/queries/0_stateless/03275_ignore_nonexistent_files_fix.reference @@ -0,0 +1,2 @@ +21 Str21 +22 Str22 diff --git a/tests/queries/0_stateless/03275_ignore_nonexistent_files_fix.sql b/tests/queries/0_stateless/03275_ignore_nonexistent_files_fix.sql new file mode 100644 index 00000000000..99c7bd12390 --- /dev/null +++ b/tests/queries/0_stateless/03275_ignore_nonexistent_files_fix.sql @@ -0,0 +1,9 @@ +-- Tags: no-fasttest + +SELECT * FROM s3( + 'http://localhost:11111/test/03036_json_archive.zip :: example11.jsonl', + JSONEachRow, + 'id UInt32, data String' + ) +ORDER BY tuple(*) +SETTINGS s3_ignore_file_doesnt_exist=1, use_cache_for_count_from_files=0;