Repository navigation
Conversation
…k/iceberg_metadata_async_iteration
…ik/iceberg_metadata_async_iteration
…com:ClickHouse/ClickHouse into divanik/iceberg_metadata_async_iteration
|
Workflow [PR], commit [059e95f] Summary: ❌
|
…k/iceberg_good_abstractions_in_manifedt_file_reader_code
…er_code' of github.com:ClickHouse/ClickHouse into divanik/iceberg_good_abstractions_in_manifedt_file_reader_code
There was a problem hiding this comment.
Pull request overview
This PR refactors Iceberg manifest handling by splitting “parsed” vs “processed” manifest entities and introducing ManifestFileIterator, with related updates to pruning, caching, and iterators consuming manifest entries (plus an integration-test update for pruning-status logging). The direction looks reasonable, but there are a few correctness/safety issues around metadata parsing and size handling that should be addressed before merge.
Changes:
- Introduce
ManifestFileIteratorand newParsedManifestFileEntry/ProcessedManifestFileEntryentities to rebuild manifest-file processing and enable streaming iteration. - Rework Iceberg metadata cache to store a cacheable manifest deserializer payload (
ManifestFileCacheableInfo) keyed by manifest path + byte size. - Update Iceberg iterators/pruning/compaction paths and adjust integration test expectations for pruning-status logging.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/integration/test_storage_iceberg_with_spark/test_system_iceberg_metadata.py | Updates integration assertions around manifest entry pruning status / row handling. |
| src/Storages/ObjectStorage/DataLakes/Iceberg/StatelessMetadataFileGetter.h | Changes manifest getter API to return cacheable info and adds helper to build a fully-initialized iterator. |
| src/Storages/ObjectStorage/DataLakes/Iceberg/StatelessMetadataFileGetter.cpp | Implements cacheable manifest loading, manifest-list parsing now records manifest byte size, and adds iterator builder that drains entries. |
| src/Storages/ObjectStorage/DataLakes/Iceberg/PersistentTableComponents.h | Adds SchemaProcessor.h include (persistent components reference schema processor). |
| src/Storages/ObjectStorage/DataLakes/Iceberg/MetadataGenerator.cpp | Adds ReadHelpers include (supporting changes elsewhere). |
| src/Storages/ObjectStorage/DataLakes/Iceberg/ManifestFilesPruning.h | Switches pruning to work with ManifestFileIterator and ProcessedManifestFileEntryPtr. |
| src/Storages/ObjectStorage/DataLakes/Iceberg/ManifestFilesPruning.cpp | Updates pruning logic to use entry->hyperrectangles and entry->parsed_entry fields. |
| src/Storages/ObjectStorage/DataLakes/Iceberg/ManifestFileIterator.h | New iterator abstraction that incrementally processes manifest rows, caches results, and supports pruning. |
| src/Storages/ObjectStorage/DataLakes/Iceberg/ManifestFileIterator.cpp | New iterator implementation: per-row processing, schema resolution, pruning, and logging. |
| src/Storages/ObjectStorage/DataLakes/Iceberg/ManifestFile.h | Refactors manifest entities into ParsedManifestFileEntry + ProcessedManifestFileEntry, adds cacheable deserializer info. |
| src/Storages/ObjectStorage/DataLakes/Iceberg/ManifestFile.cpp | Removes old eager ManifestFileContent logic; keeps comparisons and delete-matching diagnostics on processed entries. |
| src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergMetadataFilesCache.h | Changes cache payload to ManifestFileCacheableInfo and extends manifest cache key with byte size for accounting. |
| src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergMetadata.cpp | Switches manifest usage to the new iterator-based accessor for total rows/bytes and sort-order checks. |
| src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergIterator.h | Updates iterator types to use processed manifest entries and shares filter DAG via shared_ptr. |
| src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergIterator.cpp | Streams manifest entries via ManifestFileIterator::next(), sorts delete entries, and uses processed entry fields. |
| src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergDataObjectInfo.h | Updates APIs to accept processed manifest entries and delete objects. |
| src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergDataObjectInfo.cpp | Adapts object-info construction and delete attachment to the new processed entry layout. |
| src/Storages/ObjectStorage/DataLakes/Iceberg/Compaction.cpp | Adapts compaction planning to use iterator handles and processed entry partition keys. |
| src/Storages/ObjectStorage/DataLakes/Common/AvroForIcebergDeserializer.h | Adds caching for parsed manifest entries and declares methods to build them per row. |
| src/Storages/ObjectStorage/DataLakes/Common/AvroForIcebergDeserializer.cpp | Implements parsed manifest entry creation + caching, reads manifest format version from Avro metadata. |
| #include <Interpreters/ActionsDAG.h> | ||
| #include <Storages/ObjectStorage/DataLakes/Iceberg/SchemaProcessor.h> | ||
| #include <Storages/ObjectStorage/DataLakes/Iceberg/ManifestFile.h> | ||
| #include <Storages/ObjectStorage/DataLakes/Iceberg/ManifestFileIterator.h> |
There was a problem hiding this comment.
ManifestFilesPruning.h includes ManifestFileIterator.h, but the header only needs ProcessedManifestFileEntryPtr and a reference to ManifestFileIterator (which is already forward-declared). Including the full iterator header pulls in mutex/atomic/unordered_map and increases rebuild cost. Prefer including ManifestFile.h (for ProcessedManifestFileEntryPtr) and forward-declaring ManifestFileIterator, moving the iterator include to the .cpp if needed.
| #include <Storages/ObjectStorage/DataLakes/Iceberg/ManifestFileIterator.h> | |
| #include <Storages/ObjectStorage/DataLakes/Iceberg/ManifestFile.h> |
| Int64 added_sequence_number; | ||
| Int64 snapshot_id; |
There was a problem hiding this comment.
Though these two fields should be the same during all snapshots, I think it is a good idea to logically isolate it from ParsedManifestFileEntry, because they can be inherited from manifest list entry, not parsed.
| const String & common_path, | ||
| IcebergSchemaProcessor & schema_processor, | ||
| Int64 inherited_sequence_number, | ||
| Int64 inherited_snapshot_id, |
There was a problem hiding this comment.
Sorry for nit picking and asking about the older code. Why are these sequence_num and snapshot_id explicitly named as inherited_? Perhaps to make them flat sequence_number/snapshot_id here, and at ManifestFile.h as well (instead of added_)?
There was a problem hiding this comment.
Because they were "inherited" from manifest list, not read from manifest file itself. I need to rename it, you are right
| parsed_entry, common_partition_specification, file_path, resolved_sequence_number, resolved_snapshot_id, resolved_schema_id); | ||
|
|
||
|
|
||
| PruningReturnStatus pruning_status; |
There was a problem hiding this comment.
are we ok with implicit initialization of this status in case when filter_dag==nullptr?
There was a problem hiding this comment.
Good catch, I think it is important
|
|
||
| while (iterator->next()) | ||
| { | ||
| } |
There was a problem hiding this comment.
This is an illustration of abstraction mismatch, we've discussed earlier. We kinda return iterator object from a method called getManifestFileAsIterator. But this Iterator is already iterated until the end in order to have all the entries fetched. So in this context, and where it's been used, it is not actually the iterator, but the good old ManifestFile in a new shape, which has been processed using an iterator.
In my opinion, we mixed several separate abstractions together - ManifestFileIterator (which iterates over entries) and ManifestEntriesFetcher (or even -Prefetcher, as you aimed it for AsyncIterator).
Please take this comment as non-blocking thinking out loud. I wouldn't ask you to reconsider much now, when this PR is almost finished. Let's revise some of these overloaded abstractions at the next iteration of the refactoring.
| /// Compute inherited/resolved fields | ||
| const auto file_path = getProperFilePathFromMetadataInfo(parsed_entry->file_path_key, common_path, table_location); | ||
|
|
||
| Int64 resolved_snapshot_id; |
There was a problem hiding this comment.
@divanik resolved_snapshot_id is declared as an uninitialized Int64. In the else if branch at lines 405–411 (reached when parsed_snapshot_id is null and status is EXISTING), it is read uninitialized in the fmt::format call at line 411 — this is undefined behavior.
| { | ||
| throw Exception( | ||
| ErrorCodes::ICEBERG_SPECIFICATION_VIOLATION, | ||
| "Cannot read Iceberg table: manifest file '{}' has entry with snapshot_id '{}' for which write file schema is unknown", |
There was a problem hiding this comment.
the error message is incorrect — there is no snapshot_id.
Removes the `hyperrectangle` field from `DB::Iceberg::ColumnInfo` that was re-added during the frontport. The field was removed upstream in PR ClickHouse#98231, which relocated raw min/max bounds to `ParsedManifestFileEntry::value_bounds`. The `DataFileMetaInfo` Iceberg constructor now deserializes those bounds via the shared `deserializeFieldFromBinaryRepr` helper (moved from `ManifestFileIterator.cpp` to `IcebergFieldParseHelpers`). Addresses @ianton-ru's comment at #1687 (comment).
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Rebuild entities in IcebergManifestFile so code maintaining and enhancing will be less error-prone (also fixes some stuff with manifest file caching).
Preliminary PR before asyncronous Iceberg metadata iteration
Version info
26.3.1.419