Repository navigation
Use less schema comparison - #122574
Use less schema comparison#122574
Conversation
|
Workflow [PR], commit [1d81fd2] Summary: ❌
AI ReviewSummaryThis PR speeds up Iceberg manifest planning by reusing the manifest header Findings❌ Blockers
Tests
Final VerdictChanges required. LLVM Coverage ReportMeasured on commit 1d81fd2.
Changed lines: Changed C/C++ lines covered: 50/62 (80.65%) · Uncovered code |
| { | ||
| auto schema_id_string = manifest_file_deserializer_->tryGetAvroMetadataValue(f_schema_id); | ||
| Int32 schema_id = 0; | ||
| if (schema_id_string.has_value() && tryParse(schema_id, *schema_id_string) && schema_processor.isSchemaRegisteredFromMetadata(schema_id)) |
There was a problem hiding this comment.
Trusting the standalone Avro schema-id header here without cross-checking the embedded schema blob changes which schema becomes authoritative for the manifest. Before this change manifest_schema_id always came from schema_object->getValue<int>(f_schema_id). After it, a manifest whose header says schema-id = 5 but whose embedded schema object is schema-id = 7 will silently bind the manifest to schema 5 as soon as 5 is already registered from metadata.json.
That is not just a diagnostics change: buildPartitionKeyFromSpec below uses manifest_schema_id, and processRow falls back to manifest_schema_id when snapshot metadata has already been expired. So a mismatched/corrupted manifest can now change pruning and bounds decoding instead of being revalidated on the old parse path.
Please either parse just enough of schema to verify its own schema-id before taking this fast path, or fall back to the old parse-and-validate path whenever that consistency check is unavailable.
|
📊 Cloud Performance Report ✅ AI verdict: no significant changes detected. K_source=6 K_base=30 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
…pec name `generateManifestFile` stored the partition spec id in the manifest file metadata under `f_partition_spec_id`, which is `partition_spec_id`, the name of the manifest list field. The Iceberg spec and the Java implementation read the manifest header key `partition-spec-id`, so the value was never found. Add a separate `f_manifest_partition_spec_id` constant for the header key. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
There was a problem hiding this comment.
A few minor comments:
- Let's write a better changelog entry with more details about the change and what it improves. Right now it's very short and confusing for users; it's not even clear that it's related to Iceberg.
- The docs of the setting
iceberg_tolerate_conflicting_manifest_schemaspromise a warning when a manifest header schema conflicts with the one from metadata.json. After this change we never compare them, so the warning is never printed: when the header has theschema-idkey we don't parseschemaat all, and when it doesn't, the new early return inaddIcebergTableSchemaexits before the comparison. Let's just remove this warning and its mention in the setting docs and in theSettingsChangesHistory.cppentry. - Now, depending on the setting
iceberg_tolerate_conflicting_manifest_schemas, we take the manifest schema id either from theschema-idkey or from theschema-idfield insideschema. If they differ, flipping the setting changes the partition key and the schema used to read data files, while the setting is documented only as choosing whether a conflict is tolerated or throws. Let's always use theschema-idkey as the source of truth when it's present, and fall back to the id insideschemaonly when it's missing (e.g. manifests written by older ClickHouse versions). Where we parseschemaanyway, we can also check that both ids match.
…ct warning Take the manifest schema id from the `schema-id` header key whenever it is present, independently of `iceberg_tolerate_conflicting_manifest_schemas`, and fall back to the id inside `schema` only for manifests without that key. When `schema` is parsed anyway, check that both ids match. Remove the warning about a manifest header schema conflicting with metadata.json: with toleration enabled the header copy is not compared anymore, so the warning was never printed. Update the setting docs and the `SettingsChangesHistory.cpp` entry accordingly. Addresses review: #122574 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…mparison # Conflicts: # src/Core/SettingsChangesHistory.cpp
The schema written into a manifest always comes from Iceberg metadata, which requires `schema-id`, so there is no reason to skip the key silently. Addresses review: #122574 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes8 object files changed (+21.79 KiB total), 0 added.
716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units52 translation units recompiled, 556 s compile time in total, 52 of them have a recent master baseline. |
Avogar
left a comment
There was a problem hiding this comment.
Let's fix the failed integration tests and it's good to go
|
@Avogar the failed integration tests are broken in master |
|
Ah, I see, ok. Seems it's fixed in #122895. |
Cherry pick #122574 to 26.3: Use less schema comparison
Cherry pick #122574 to 26.7: Use less schema comparison
Cherry pick #122574 to 26.8: Use less schema comparison
Cherry pick #122574 to 26.9: Use less schema comparison
Backport #122574 to 26.7: Use less schema comparison
Backport #122574 to 26.9: Use less schema comparison
Backport #122574 to 26.8: Use less schema comparison
Backport #122574 to 26.3: Use less schema comparison

We spend a lot of time on schema comparison. Let's use it less
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Faster planning of queries to Iceberg tables with many manifest files: when a manifest file header has the
schema-idkey and that schema is already known from metadata.json, the schema copy stored in the manifest header is no longer parsed and compared with it. ClickHouse now also writes theschema-idkey into the headers of manifest files it creates.Workflow [PR]
Sync PR [sync-upstream/pr/122574]
Version info
26.10.1.1028-master(included in26.10and later)26.9.9.21,26.8.16.29,26.7.20.18,26.3.40.8