Repository navigation
Conversation
…reader carries
An Iceberg partition field may reference a nested source field, in which case the
manifest value was emitted under the field's dot-joined full name and matched against
the format header by that string. The string is neither the name the header carries nor
a key that identifies the field, so the value was silently replaced by the column
default in four reachable situations:
- every table-level format other than `Parquet`, where the requested subcolumn
collapses to its parent and the header holds `s` rather than `s.c`;
- `SELECT s` on any format, `Parquet` included, which only ever puts `s` in the
header, so the engine answered `'x'` for `SELECT s.c` and `(NULL,NULL)` for
`SELECT s` on the same datum;
- a query that requests an ancestor alongside the leaf, leaving only the
intermediate tuple in the header;
- a filter the reader evaluates itself, which sees the default-filled parent and
drops the matching rows rather than nulling a column.
Iceberg also permits a dot in a field name, so one joined name can denote two distinct
fields, and the name alone cannot tell them apart.
Resolve each identity column to its `source_id`-backed segmented element path on the
producer, where `source_id` and the schema processor are both already in hand; there,
enumerate one candidate injection site per ancestor prefix and drop any whose joined
name the schema does not uniquely identify, which is the same policy
`tupleElementNameIsAmbiguousWhenFlattened` applies to that ambiguity. The reader then
matches whichever ancestor its header carries and rebuilds that tuple positionally with
only the partition element replaced, so every sibling element still comes from the file.
The root prefix is exempt from the uniqueness test, because an identifier lookup
resolves a top-level column before a subcolumn.
A top-level field has a one-segment path and therefore exactly one whole-column site,
which is the existing code path unchanged. The site list crosses the cluster wire under
a new protocol version. A peer that predates it receives only the columns whose joined
name identifies them, and gets that single site synthesized; a column whose joined name is
ambiguous is omitted rather than sent to be injected into the wrong column.
The nested `SELECT s` assertion in `test_identity_partition_column_nested_field` moves
as a result: the value it pinned contradicts the same engine's answer to `SELECT s.c`
two lines above it.
The uniqueness test is covered over the schema processor directly, where a colliding schema
needs no writer, and end to end by appending the colliding top-level field to the snapshot's
schema after the write: pyiceberg refuses to write a schema whose fields share a flattened
name.
Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; three passes, one full plus two delta
Two notes I recorded and did not act on, both unreachable from a planner-built plan: Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20260830-045200 |
Pre-PR validation gate (click to expand)
Eight mutations were run, each alone, each reddening only named arms and leaving the rest green: Session id: cron:clickhouse-impl-slot-4:20260830-035800 |
|
Workflow [PR], commit [3feb4b7] Summary: ✅
AI ReviewSummaryThis PR restores nested Iceberg identity partition values when the reader carries an ancestor tuple, preserves sibling values from the file, updates reader-side filtering, and transports injection sites under cluster protocol version Consumer tracing covered the iterator and compaction producers, projection, row-policy and Missing context / blind spots
Findings
Final Verdict
|
|
cc @SmitaRKulkarni @devcrafter, could you review this? A nested Iceberg identity partition value was matched to an output column by its dot-joined name against the format header, which is neither the name the header carries nor a key that identifies the field, so |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes19 object files changed (+231.96 KiB total), 0 added.
719 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 units342 translation units recompiled, 3370 s compile time in total, 342 of them have a recent master baseline. Median compile-time ratio to the baselines is ×0.95 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
Two conflicts, both resolved by re-applying this branch's addition on top of master's newer code: - src/Core/ProtocolDefines.h: master took cluster protocol version 11 for Iceberg deletion vectors, so the identity-partition-paths version becomes 12. A number must never carry two meanings, so master's 11 is kept as it is and this branch renumbers. - Iceberg/SchemaProcessor.cpp: master restructured addSchemaImpl (empty field name validation, current_schema_id set around the build loop, manifest_sourced_schema_ids registration). The per-field path tracking, the clickhouse_paths_by_source_ids write and the flattened-name census are re-applied inside that structure, with the census running before the manifest registration so a manifest-sourced schema is censused too. Submodules are at master's pins.
…ey describe Master's manifest-first replacement path (dropCachedSchema, added while this branch was open) erases everything derived from a schema that a manifest header registered before metadata.json settled the same schema-id. The two maps this branch adds were not in that list: - flat_name_counts is a count, not a presence bit, so the rebuild incremented every name of the replaced copy to two. flatNameIdentifiesOneColumn then reported ambiguity for names that only one column carries, the leaf injection site was dropped, and a nested identity value stopped reaching the column the reader carries: exactly the defect this branch fixes, back again after a maintenance entrypoint reached a manifest header first. - clickhouse_paths_by_source_ids outlived the fields it describes, so getFieldPath answered for a source id whose type lookup already throws, which is the invariant its declaration states. The regression test is armed: with the two erasures removed it fails on both oracles (ambiguous `s.c`, and a stale path for a dropped field), and passes with them.
CI finish ledger - 0d613aaEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20260920-050147 |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
TopN dynamic filtering compares the values the reader returns against the threshold, so it is refused for a column whose final values differ from the reader's. An identity partition value of a nested field is now also injected into its ancestor tuples (`address` for `address.country`), so match the sort column against every injection site rather than only against the joined name. A column deserialized from an older peer carries its joined name as its only site, so that case keeps the previous check. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…the data file The `nested_source` table of the DuckDB Iceberg extension tests is partitioned by identity on `address.country`, and its data file stores only `address.city`, so the value is only in the manifest. `SELECT *`, an explicit PREWHERE over `address` and a post-reader filter over `address` returned NULL for it. The table files are byte-identical to those of ClickHouse#130010 at the same path. Closes ClickHouse#129995 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…m_data_file` Readers on master take `file_size_in_bytes` of the manifest entry as the length of a Parquet data file, so a file rewritten shorter in place was read past its end (`ACCESS_DENIED` for the catalog table of `test_identity_partition_column_nested_field_sibling_kept_in_data_files`). Reuse `set_file_size_in_manifests`, which `drop_column_from_data_file` already calls for the same reason. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…alue lands in
The data files of `..._nested_field_sibling_kept_in_data_files` store `s`
without its partition leaf `c`, so the reader decodes `(NULL, 10)` and
`(NULL, 20)` while the query returns the rebuilt `('x', 10)` and `('y', 20)`.
A TopN threshold applied inside the reader to the decoded tuples drops the
row of the file read second, which for `ORDER BY s DESC LIMIT 1` is the
top row. With the guard matching only the joined name `s.c`, that query
returned `('x',10)` in 5 of 5 runs; with TopN disabled, or with the guard
matching every injection site, it returns `('y',20)`.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Shorten the Iceberg identity injection-site comments to the invariants a reader needs; drop design narration. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (codex, Gate B, 2 rounds) plus my own cold review of the merged tree.
|
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-7:20261108-025600 |
|
cc @scanhex12 @alesapin, could you review this? A nested Iceberg identity partition value (e.g. |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Version 16 sends the injection sites of every Iceberg identity partition value, so the native protocol spec has to name it (.claude/CLAUDE.md requires a spec update for a protocol version bump). Version 15 (the byte range of a Parquet file bucket, ClickHouse#125636) was never added to the spec, so it is documented here as well; the spec still said 14. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
Closes: #129995
Related: #116129 (the mechanism this lands in)
Related: #130010 (adds the same DuckDB table and waits for this fix)
Found by a review comment on #113650 (comment)
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed reading an Iceberg table whose identity partition field is a nested field, such as
address.country, that the data files do not store. The value from the manifest was replaced byNULLunless the query read exactly that subcolumn of aParquettable:SELECT *andSELECT addressreturned(NULL,'paris'),SELECT address.countryreturnedNULLfor the other table-level formats, and aPREWHEREover the parent tuple dropped the matching rows.Description
On 26.10.2.103,
SELECT * FROM icebergLocal(...)over the DuckDBnested_sourcetable of #129995 returns1 (NULL,'paris')instead of1 ('fr','paris').The manifest value is matched to a reader column by the field's dot-joined name (
address.country). The header carries that name only when the query reads exactly that subcolumn of aParquettable; otherwise it carries the parent tuple (or an intermediate one), nothing matches, and the reader's default stays.This resolves each identity field to its
source_id-backed element path, offers one injection site per ancestor prefix, and rebuilds the parent tuple positionally with only that element replaced, so the siblings still come from the file. A prefix whose flattened name denotes two columns (Iceberg allows a dot in a field name) is dropped. The same sites gate the in-reader filters and TopN dynamic filtering. A top-level field keeps today's path. TheSELECT id, sassertion pinned by #116129 moves from(NULL,NULL): that is the fix.The sites reach cluster workers under protocol version 16. An older peer receives only the columns whose joined name is itself a site, so a mixed-version cluster degrades to today's behaviour (serde
gtest; not reachable from SQL).Tests: the issue's table as a stateless test (3 of its 4 queries fail on master), and integration arms for non-
Parquetformats, intermediate tuples, ambiguous names,PREWHERE, TopN dynamic filtering andicebergS3Cluster.One question: is cluster-protocol version 16 free in the private repository?
ProtocolDefines.hreserves 7 for that reason. Happy to renumber.Workflow [PR]
Sync PR [sync-upstream/pr/117122]