Skip to content

Cherry pick #111786 to 26.7: Fix missing Iceberg field-ids in ClickHouse-written manifest and manifest-list files - #117304

Merged
PedroTadim merged 4 commits into
backport/26.7/111786from
cherrypick/26.7/111786
Sep 1, 2026
Merged

PedroTadim merged 4 commits into
backport/26.7/111786from
cherrypick/26.7/111786

Conversation

@robot-ch-test-poll3

Copy link
Copy Markdown
Contributor

Original pull-request #111786

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

groeneai and others added 3 commits July 24, 2026 12:11
The bundled avro-cpp JSON compiler drops the Iceberg field-id/element-id
attributes, so the schema it serialized into the avro.schema header of a
ClickHouse-written manifest / manifest-list omitted them. External readers
(PyIceberg, Spark) reject such a schema during scan planning ("Cannot convert
field, missing field-id"), while ClickHouse itself reads via the Iceberg
schema metadata key and did not notice.

generateManifestFile and generateManifestList now write the original
id-carrying JSON schema string as the avro.schema header. Encoded data is
unchanged; only the header schema now carries the spec field-ids it should.

Also derive the manifest partition-struct field-id from the persisted
partition spec instead of the hardcoded 1000+i: ClickHouse numbers partition
fields from 1001, and Iceberg projects partition values by field-id, so the
previously-invisible mismatch would break external readers once the id is
emitted. Legacy v1 specs that do not track partition field-ids fall back to
the sequential 1000+i default.

Closes: #111763

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…eld-ids-111763

Fix missing Iceberg field-ids in ClickHouse-written manifest and manifest-list files
@robot-ch-test-poll3 robot-ch-test-poll3 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels Aug 31, 2026
Resolved tests/integration/test_storage_iceberg_with_spark/test_writes_field_ids_spark_read.py.

26.7 does not have a10d171 ('Embed Iceberg field IDs in Avro and ORC data
files'), so the file does not exist there and the merge saw a modify/delete.
Taking master's copy wholesale would add 4 tests for data-file field-ids that
26.7 never writes (verified: ORCBlockOutputFormat.cpp has no 'iceberg.id' on
26.7), so the file is trimmed to the part this PR is about: the _avro_field_ids
helper it depends on, _avro_metadata_schemas, and test_writes_manifest_field_ids_spark_read,
all copied verbatim from master.

The src change is self-contained on 26.7: DEFINE_ICEBERG_FIELD_ALIAS and every
f_* constant it uses already exist, partition_spec is already a parameter of
generateManifestFile, and extendSchemaForPartitions has a single call site,
which is updated.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@PedroTadim
PedroTadim merged commit 16f2dd7 into backport/26.7/111786 Sep 1, 2026
1 check passed
@PedroTadim
PedroTadim deleted the cherrypick/26.7/111786 branch September 1, 2026 11:37
PedroTadim added a commit that referenced this pull request Sep 1, 2026
Two conflicts, both resolved toward 26.6's existing shape.

src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergWrites.cpp: master spells the
extendSchemaForPartitions parameter 'const DataTypes &' where 26.6 spells the same
type 'const std::vector<DataTypePtr> &' (also in IcebergWrites.h). Kept 26.6's
spelling and added the new partition_spec_fields parameter.

tests/integration/test_storage_iceberg_with_spark/test_writes_field_ids_spark_read.py:
26.6 does not have a10d171 ('Embed Iceberg field IDs in Avro and ORC data
files') - verified by content, ORCBlockOutputFormat.cpp has no 'iceberg.id' on
26.6 - so the file does not exist there and the merge saw a modify/delete. Trimmed
to the part this PR is about: the _avro_field_ids helper it depends on,
_avro_metadata_schemas, and test_writes_manifest_field_ids_spark_read, copied
verbatim from master. Matches the 26.7 cherry-pick (#117304) byte for byte.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants