Skip to content

Inject a nested Iceberg identity partition value into the column the reader carries - #117122

Open
groeneai wants to merge 13 commits into
ClickHouse:masterfrom
groeneai:iceberg-nested-identity-partition-injection
Open

groeneai wants to merge 13 commits into
ClickHouse:masterfrom
groeneai:iceberg-nested-identity-partition-injection

Conversation

@groeneai

@groeneai groeneai commented Aug 30, 2026 •

Copy link
Copy Markdown
Collaborator

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):

  • Bug Fix (user-visible misbehavior in an official stable release)

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 by NULL unless the query read exactly that subcolumn of a Parquet table: SELECT * and SELECT address returned (NULL,'paris'), SELECT address.country returned NULL for the other table-level formats, and a PREWHERE over the parent tuple dropped the matching rows.

Description

On 26.10.2.103, SELECT * FROM icebergLocal(...) over the DuckDB nested_source table of #129995 returns 1 (NULL,'paris') instead of 1 ('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 a Parquet table; 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. The SELECT id, s assertion 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-Parquet formats, intermediate tuples, ambiguous names, PREWHERE, TopN dynamic filtering and icebergS3Cluster.

One question: is cluster-protocol version 16 free in the private repository? ProtocolDefines.h reserves 7 for that reason. Happy to renumber.


Workflow [PR]
Sync PR [sync-upstream/pr/117122]

…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]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-review-bot PR origin: review-bot finding on a groeneai PR labels Aug 30, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
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
rechecks after fix rounds; 5 findings), plus my own cold review of the resulting tree each round,
taken before reading the implementation notes (4 findings). The final pass returned 0 findings. The
branch is a single commit, so every fix below is in it.

# Sev Finding Verdict Evidence / action
1 ⚠️ No test proves that rebuilding a parent tuple preserves a non-partition sibling read from the file (test_identity_partition_column_projection.py) AGREE, fixed Every nested fixture removed the WHOLE parent column, so a sibling's expected value was the default and a defaults-based rebuild would have passed. Added a helper that removes one struct field, and an arm whose data files keep s.d while omitting only s.c. It reddens on the pre-fix binary, where s.d still arrives from the file, so the arm isolates the injected leaf.
2 ⚠️ A protocol downgrade describes a nested field by its joined name alone, so a peer can inject the value into an unrelated column of that name (IcebergDataObjectInfo.cpp) AGREE in part, fixed Narrowed to the serializer, the direction I control. Below the new version I now send only the columns whose own joined name is one of their injection sites, so an ambiguous name is omitted rather than sent to be matched by name. Top-level fields, including a dotted top-level name, are unaffected. I disagreed on extending it to the deserializer: no schema is in scope there to tell a nested joined name from a legitimately dotted top-level one. In both mixed-version directions the result is today's, never a wrong value.
3 ⚠️ The dotted-name test never exercises the ambiguity-rejection guard (SchemaProcessor.cpp, test_identity_partition_column_projection.py) AGREE, fixed Raised twice, and correct both times: the existing arm's source is top-level, which the guard deliberately exempts, so forcing the guard permissive changed no arm. My first prescription failed, because pyiceberg refuses to write a schema whose fields share a flattened name. Fixed two ways instead. Three unit arms call the predicate directly and are live in both directions, so neither accepting nor declining everything passes. And an end-to-end arm builds the collision by appending the colliding field to the snapshot's schema after the write: with the guard forced permissive, the unrelated top-level column named s.c returns the partition value instead of its own NULL, while the arm's other assertion still passes.
4 ❌ Version 11 must be confirmed unused in the private repository before assigning it to this wire layout (ProtocolDefines.h) DISAGREE Agreed on the risk, and it is asked in the description rather than absorbed here: closing this finding needs an authoritative search of a repository I cannot read. ProtocolDefines.h:46-48 is the precedent for a reserved slot, and I will renumber on request. I checked that #116171, the other open Iceberg protocol PR, does not touch this file.
5 ⚠️ The branch's first commit was labelled WIP AGREE, fixed Collapsed to a single commit before the first push, so the message that reaches master is the full one.
6 💡 An early return in substituteIdentityPartitionColumns is unreachable AGREE, fixed Both call sites gate on the same predicate over the same inputs, and merging an empty set of substitutions is already correct. Removed.
7 💡 Two added lines exceed the .clang-format column limit AGREE, fixed Wrapped using the in-file precedent. No added line now exceeds it.

Two notes I recorded and did not act on, both unreachable from a planner-built plan:
getRequiredColumns does not deduplicate by name, so a filter with two inputs of one name would get
a single substitution; and the tuple rebuild costs one tupleElement per element per file, which is
a per-block pointer operation rather than a per-row cost.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding.

Session id: cron:clickhouse-review-slot-8:20260830-045200

@clickhouse-gh clickhouse-gh Bot closed this Aug 30, 2026
@clickhouse-gh clickhouse-gh Bot reopened this Aug 30, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. pytest test_storage_iceberg_no_spark/test_identity_partition_column_projection.py::test_identity_partition_column_nested_field_non_parquet_format fails on the pre-fix binary every run: a fixed pyiceberg fixture and a fixed query, nothing randomized.
b Root cause explained? The manifest value is matched to an output column by the field's dot-joined name against the format header (StorageObjectStorageSource.cpp:289). That string is not the name the header carries (a non-Parquet format collapses s.c to s; SELECT s and SELECT s.t, s.t.c do the same on any format) and does not identify the field (Iceberg permits a dot in a field name).
c Fix matches root cause? The match is replaced where the field's identity still exists: Utils.cpp:1635 holds source_id and discarded it. No widened bound, no no-random-* tag, no guard at the symptom site.
d Test intent preserved / new tests added? One merged assertion moves, deliberately: test_identity_partition_column_nested_field:528 pinned SELECT id, s to (NULL,NULL) while the same test asserts 'x' for SELECT s.c two lines above, on the same datum. Its projection and filtered assertions are byte-identical. Eight new integration arms, two new arms in the existing serde gtest (where identity_partition_columns had no coverage) and three in the schema-processor gtest. Nothing weakened or removed.
e Both directions demonstrated? Yes. Same tree, src/ reverted: 8 failed, 9 passed. With the fix: 17 passed. Build-IDs d831debad34cf844 (base) and e42f8c874da614ae (fix). The 9 that pass on both are the 8 pre-existing arms the PR leaves untouched, plus the new dotted-top-level arm, which is a non-regression arm and is green on master by design; the 8 that fail on base are the 7 other new arms and the one pre-existing arm whose assertion moves.
f Fix is general across code paths? All four consumers share one predicate and one replacement helper: the projection DAG, readsIdentityPartitionColumn, substituteIdentityPartitionColumns (row-level filter and PREWHERE) and the cluster wire. Both producers pass the vector through unchanged; the pruning paths key off numeric source ids and are untouched.
g Fix generalizes across inputs (params/datatypes/wrappers)? Formats: Parquet plus declared ORC / Avro / Native. Nesting depth 1, 2 and 3. One and two identity fields under one parent. Header shapes: flattened leaf, intermediate tuple, root tuple. Names: plain and dotted top-level. Sibling preservation has its own arm, whose data files keep s.d = 10 / 20 and omit only the partition leaf, so the sibling's file value differs from the type default and a rebuild from defaults reddens it. Boundary rows: a 0-row block, the count() path and GROUP BY s over the rebuilt tuple. Wrapper types the lake schema cannot produce (Nullable tuple, Array, Map, unnamed tuple) are declined rather than guessed. A flattened name shared by two columns is covered in both directions: a top-level dotted name still resolves to its own column, while a nested leaf whose joined name an unrelated top-level column also spells is declined, with a unit arm over the schema processor and an end-to-end arm.
h Backward compatible? (maintainer-approved exception only) Yes. No setting default changes, so no SettingsChangesHistory.cpp entry. The wire field rides a new protocol version 11, following the three version gates already in the same function; a peer at protocol <= 10 receives only the columns whose joined name identifies them, and gets that single site synthesized, reproducing today's exact-name match; a column whose joined name is ambiguous is omitted rather than sent to be injected into the wrong place. Both halves are asserted by their own gtest arm. On-disk formats untouched.
i Invariants and contracts preserved? The rebuilt tuple keeps the parent's type verbatim, so no nullability or type drift, and several identity fields under one parent compose as chained nodes. Every non-partition element comes from the file. The whole-column path adds no DAG input, so the reader is never asked for a column the data file need not contain. getFieldPath throws rather than returning an empty path, so an empty site list means only a protocol downgrade. Transform order in createReader unchanged. Both new maps are written under the exclusive lock already held and read under SharedLockGuard, like their siblings.

Eight mutations were run, each alone, each reddening only named arms and leaving the rest green:
splitting the joined name instead of resolving by source_id; emitting only the leaf and root site;
dropping the protocol-downgrade synthesis; applying the uniqueness test to the root prefix;
restricting the in-reader substitution to whole-column sites (that one loses the matching row entirely,
which proves the PREWHERE arm is armed rather than merely green); taking the non-partition tuple
elements from type defaults instead of from the file; dropping the omission of an ambiguous column
at protocol <= 10; and making the flattened-name uniqueness test permissive, which returns the
partition value in place of an unrelated top-level column's own data.

Session id: cron:clickhouse-impl-slot-4:20260830-035800

@clickhouse-gh

clickhouse-gh Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [3feb4b7]

Summary: ✅


AI Review

Summary

This 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 16. Reviewed head 3feb4b73fb10f93c1bb3d10b63e2facbea3020dc. No new inline findings. The protocol documentation finding is fixed and its thread was resolved; the earlier cross-repository protocol-allocation concern remains a verification request.

Consumer tracing covered the iterator and compaction producers, projection, row-policy and PREWHERE substitution, TopN filtering, and cluster serialization/deserialization. Tuple reconstruction preserves the reader header's names and types before delete transforms and schema evolution.

Missing context / blind spots
  • ⚠️ The private repository returned HTTP 404, so the shared protocol allocation could not be checked. Confirmation from a maintainer with access would close this compatibility gap.
  • ⚠️ No runnable ClickHouse binary or build tree is available locally. Runtime evidence comes from the author's reported regression runs and the checked-in tests; head unit and integration CI jobs were still running when reviewed.
Findings

⚠️ Majors

  • src/Core/ProtocolDefines.h:60 Shared protocol allocation needs verification. [dismissed by author -- https://github.com/Inject a nested Iceberg identity partition value into the column the reader carries #117122#discussion_r3888607959] The original concern now applies to version 16: if the private repository assigns that number to a different layout, peers can negotiate the same version while decoding different read-task payloads. This is an unverified risk, not an observed collision. A successful textual merge alone would not prove the layouts agree, and CH Inc sync is currently pending. Confirm that 16 is free or reserved for this extension in the private repository; renumber consistently if needed. No reply or reopening was made on the dismissed thread.
Final Verdict

⚠️ Request changes — confirm the shared allocation of protocol version 16. No additional code change is requested if that allocation is confirmed.

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Aug 30, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

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 SELECT s.c read NULL on every non-Parquet format and SELECT s read (NULL,NULL) even on Parquet; I now resolve the column to its source_id-backed element path and rebuild the parent tuple with only that element replaced. The cluster-protocol half adds version 11 to carry those paths, and there is an open question in the description about whether that number is free in the private repository.

Comment thread src/Core/ProtocolDefines.h Resolved
@clickhouse-gh

clickhouse-gh Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 3feb4b73f with master 7b5f2bf32 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

19 object files changed (+231.96 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Storages/ObjectStorage/StorageObjectStorageSource.cpp.o 1.12 MiB 1.26 MiB +140.87 KiB (+12.29%)
src/CMakeFiles/dbms.dir/Storages/ObjectStorage/DataLakes/Iceberg/SchemaProcessor.cpp.o 554.38 KiB 580.77 KiB +26.39 KiB (+4.76%)
src/CMakeFiles/dbms.dir/Storages/ObjectStorage/DataLakes/Iceberg/IcebergDataObjectInfo.cpp.o 257.53 KiB 279.43 KiB +21.89 KiB (+8.50%)

719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

342 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.
The matched translation units cost -173.6 s (-5%) in total before that adjustment.

Job report

@clickhouse-gh clickhouse-gh Bot added the comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. label Sep 4, 2026
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.
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 0d613aa

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Build profile diff infra, not from this diff: RuntimeError: CI logs cluster query failed raised at ci/jobs/build_profile_diff_job.py:234 from compare_opt_functions (:999), after repeated ReadTimeouts from ci/jobs/scripts/log_cluster.py:333 against the CI logs cluster host #118708 (mine, open)
PR praktika rollup of the row above, which is the only red job of the 176 checks on this head #118708 (mine, open)

CH Inc sync and Mergeable Check are green on this head, so neither is listed. The 18 Bugfix validation (integration tests, aarch64/amd64) CIDB FAIL rows at this commit are the intended inversion, not failures: they are this PR's own 9 new test_storage_iceberg_no_spark/test_identity_partition_column_projection.py tests failing against the pre-fix binary, and both checks report check_status = success.

Session id: cron:our-pr-ci-monitor:20260920-050147

groeneai and others added 2 commits November 8, 2026 02:59
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]>
groeneai and others added 4 commits November 8, 2026 03:18
…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]>
@groeneai

groeneai commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator Author
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.

Finding Verdict
⚠️ No test proved TopN dynamic filtering is refused for a struct a nested identity value lands in AGREE, fixed: ASC/DESC ORDER BY s LIMIT 1 arm in ..._sibling_kept_in_data_files fails 5/5 with the guard matching only s.c, passes 5/5 with the fix
❌ Cluster-protocol 16 not proven free in the private repository DISAGREE: not visible from this repository; the question is in the description, and the CH Inc sync merge would conflict on the same line if 16 were taken
❌ A pre-16 initiator's nested s.c can overwrite a top-level column named s.c on a new worker DISAGREE: under the old layout a new worker reads the task exactly as an old one does (same name match, same constant); dropping dotted names instead would lose the value on the Parquet subcolumn path that works today
⚠️ The TopN arm does not assert that TopN was armed DISAGREE: with TopN disabled the guard-reverting build passes, so the failure comes from TopN; if TopN stops being armed, the hazard goes with it
💡 05577 arm 2 passes on master too Kept: it is the issue's own expectation; arms 1, 3, 4 fail on master

@groeneai

groeneai commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. SELECT * FROM icebergLocal('data/persistent/partition_values_missing_from_files/warehouse/default/nested_source') ORDER BY ALL, run from tests/queries/0_stateless/data_iceberg/duckdb, returns 1 (NULL,'paris') on every run on 26.10.2.103 and on master.
b Root cause explained? The manifest value is keyed by the field's dot-joined name address.country; the projection (buildIdentityPartitionColumnsDag) and the in-reader filters only inject when the reader header has a column of exactly that name, which happens only for a Parquet read of exactly that subcolumn. SELECT *, SELECT address or a filter over address put the parent tuple in the header, so nothing is injected and the reader's default (NULL) stays.
c Fix matches root cause? Yes. Each identity value carries one injection site per ancestor prefix of its source_id-backed path; every consumer (projection, row-level filter, PREWHERE, TopN guard) matches sites and rebuilds the parent tuple with only that element replaced.
d Test intent preserved / new tests added? New stateless test with the issue's table (4 queries) plus integration arms for non-Parquet formats, intermediate tuples, ambiguous flattened names, PREWHERE, TopN dynamic filtering and icebergS3Cluster; gtests for the schema census and the old-peer serialization. The one moved assertion is the (NULL,NULL) the fix removes.
e Both directions demonstrated? Stateless test: master returns (NULL,'paris') and nothing for the two address = ('fr','lyon') filters (3 of 4 queries differ); the fix matches the reference, 50/50 runs. Integration file 24/24 on the fix; its TopN arm fails 5/5 with the guard matching only the joined name (ORDER BY s DESC LIMIT 1 returns ('x',10)).
f Fix is general across code paths? All readers of identity_partition_columns were enumerated: post-reader projection, row-level filter, PREWHERE, TopN dynamic filtering, cluster serialization, compaction (same source, so it now writes the injected value), the iterator (producer).
g Fix generalizes across inputs (params/datatypes/wrappers)? Depth 1 and 2, sibling stored or absent, whole struct absent, non-Parquet table-level formats, a dotted top-level name colliding with a subcolumn, and a column read through an array of tuples (not a site). Iceberg structs map to Tuple with Nullable elements; lists and maps are never paths.
h Backward compatible? Yes. New cluster-protocol version 16; an older peer gets only the columns whose joined name is itself a site, which is today's behaviour. No setting changes.
i Invariants and contracts preserved? The rebuilt tuple is cast back to the column's own named type, so the header type is unchanged; a whole-column site stays a constant, so the file is never asked for a column it does not store; ambiguous flattened names never receive a value.

Session id: cron:clickhouse-impl-slot-7:20261108-025600

@groeneai

groeneai commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator Author

cc @scanhex12 @alesapin, could you review this? A nested Iceberg identity partition value (e.g. address.country) was injected only when the reader header carried exactly that subcolumn, so SELECT * returned (NULL,'paris'); this resolves the field's element path, offers one injection site per ancestor prefix and rebuilds the parent tuple with only that element replaced, sent to cluster workers under protocol version 16 (please check that 16 is free in the private repository).

@clickhouse-gh clickhouse-gh Bot added manual approve Manual approve required to run CI submodule changed At least one submodule changed in this PR. labels Nov 8, 2026
@clickhouse-gh
clickhouse-gh Bot requested review from leshikus and maxknv November 8, 2026 05:55
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread src/Core/ProtocolDefines.h Resolved
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]>
@mintlify

mintlify Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 3feb4b7.

Approve preview

@clickhouse-gh clickhouse-gh Bot added comp-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... and removed comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. labels Nov 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... groeneai-origin-review-bot PR origin: review-bot finding on a groeneai PR manual approve Manual approve required to run CI pr-bugfix Pull request with bugfix, not backported by default submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Iceberg: identity partition value is not used for a nested struct field missing from the data file (NULL instead of the value)

2 participants