Skip to content

Field ids for data files in iceberg writes - #102362

Merged
scanhex12 merged 9 commits into
ClickHouse:masterfrom
scanhex12:iceberg_field_ids_data_files
May 15, 2026
Merged

scanhex12 merged 9 commits into
ClickHouse:masterfrom
scanhex12:iceberg_field_ids_data_files

Conversation

@scanhex12

@scanhex12 scanhex12 commented Apr 10, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Field ids for data files in iceberg writes. Closes #102322

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.5.1.673

@clickhouse-gh

clickhouse-gh Bot commented Apr 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [a089160]

Summary: ⏳

job_name test_name status info comment
Stateless tests (amd_msan, WasmEdge, parallel, 2/2) FAIL
01548_query_log_query_execution_ms FAIL cidb
Upgrade check (amd_release) FAIL
Error message in clickhouse-server.log (see upgrade_error_messages.txt) FAIL cidb

AI Review

Summary

This PR wires Iceberg field_id propagation into more Parquet write paths (INSERT/UPDATE/compaction), fixes FormatFactory propagation for non-parallel output, and removes dead ArrowFieldIndexUtil code. The core implementation changes are directionally correct, but two coverage gaps remain that leave key parts of the promised behavior unproven.

Findings

⚠️ Majors

  • [tests/integration/test_storage_iceberg_with_spark/test_writes.py:210] test_writes_parquet_field_ids_complex_types still validates only top-level Parquet fields (x, z, y). The PR changes nested propagation logic (element/key/value and tuple members), but regressions in nested IDs would still pass.
    Suggested fix: recursively walk the Parquet schema tree and assert PARQUET:field_id for nested fields such as x.element, z.key, z.value, y.zip, y.foo.
  • [src/Storages/ObjectStorage/DataLakes/Iceberg/Compaction.cpp:290] The compaction write path is now responsible for preserving field_id during OPTIMIZE, but there is still no focused integration test that validates rewritten files after compaction. Current added tests cover insert/update writes only.
    Suggested fix: add one focused integration test that runs OPTIMIZE and verifies PARQUET:field_id in rewritten data files (preferably including at least one nested field).
Tests
  • ⚠️ Missing regression evidence for nested Parquet field_id propagation in complex types.
  • ⚠️ Missing regression evidence for field_id preservation in compaction (OPTIMIZE) rewrites.
Final Verdict

Status: ⚠️ Request changes

Minimum required actions:

  1. Add recursive nested-field assertions in test_writes_parquet_field_ids_complex_types.
  2. Add a focused OPTIMIZE/compaction test that validates PARQUET:field_id in rewritten data files.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Apr 10, 2026
@alesapin alesapin self-assigned this Apr 10, 2026

for path in parquet_files:
schema_pq = pq.read_schema(path)
for field in schema_pq:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ This test only validates top-level Parquet field_id values. Because this PR changes nested propagation for list/map/tuple paths (element, key, value), regressions in nested IDs would still pass.

Please add recursive assertions for nested fields (e.g. x.element, z.key, z.value, y.zip, y.foo) by walking the Parquet schema tree, not only for field in schema_pq.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still unaddressed in the current revision.

test_writes_parquet_field_ids_complex_types still validates only top-level fields:

  • loop is for field in schema_pq (tests/integration/test_storage_iceberg_with_spark/test_writes.py:210)
  • expected ids map only contains {\"x\", \"z\", \"y\"} (:197)

So regressions for nested IDs like x.element, z.key, z.value, y.zip, y.foo would still pass. Please add recursive schema checks for nested fields.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still live in the current revision.

test_writes_parquet_field_ids_complex_types still only iterates top-level fields (for field in schema_pq) and only checks {"x", "z", "y"}. That cannot catch regressions in nested IDs (x.element, z.key, z.value, y.zip, y.foo) even though this PR changes nested propagation logic in PrepareForWrite.

Please walk the Parquet schema recursively and assert PARQUET:field_id for nested fields as well.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still unresolved in the current code.

test_writes_parquet_field_ids_complex_types still checks only top-level fields:

  • it iterates for field in schema_pq (tests/integration/test_storage_iceberg_with_spark/test_writes.py:209), and
  • expected IDs include only {"x", "z", "y"} (:197).

So regressions in nested IDs (x.element, z.key, z.value, y.zip, y.foo) would still pass. Please recurse through the Parquet schema tree and assert PARQUET:field_id for nested fields too.

@alexey-milovidov

Copy link
Copy Markdown
Member

The FileCacheTest.SLRUFreeSpaceKeepingProtectedOnly failure on this PR is a known flaky test that was fixed in #104418. Could you please update the branch with the latest master to pick up the fix?

@scanhex12
scanhex12 force-pushed the iceberg_field_ids_data_files branch 2 times, most recently from 2d62a47 to 7df75a0 Compare May 13, 2026 13:57
= FormatFactory::instance().getOutputFormat(write_format, *write_buffer, *sample_block, context, format_settings);
FormatFilterInfoPtr output_format_filter_info
= std::make_shared<FormatFilterInfo>(nullptr, context, column_mapper, nullptr, nullptr);
auto output_format = FormatFactory::instance().getOutputFormat(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ This code path is now responsible for preserving Iceberg field_id values during OPTIMIZE rewrites, but the added tests do not validate this path. Existing compaction tests in test_optimize.py only check row-level correctness/statistics, so dropping column_mapper wiring here would still pass CI.

Please add one focused integration assertion after OPTIMIZE that inspects a rewritten data Parquet file and checks PARQUET:field_id (ideally including one nested field).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This point is still live in the current revision.

The newly added tests cover insert and update writes, but there is still no assertion for the compaction rewrite path (OPTIMIZE). If writeDataFiles in compaction drops FormatFilterInfo/column_mapper wiring in a future change, current tests would not catch it.

Please add one focused integration check that runs OPTIMIZE and verifies PARQUET:field_id in the rewritten data file (ideally including at least one nested field).

@asya-ch asya-ch self-assigned this May 13, 2026

@asya-ch asya-ch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See suggestions.

@scanhex12
scanhex12 enabled auto-merge May 15, 2026 11:26
@clickhouse-gh

clickhouse-gh Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.10% 84.10% +0.00%
Functions 92.00% 92.00% +0.00%
Branches 76.50% 76.60% +0.10%

Changed lines: 75.19% (97/129) | lost baseline coverage: 11 line(s) · Uncovered code

Full report · Diff report

@scanhex12
scanhex12 added this pull request to the merge queue May 15, 2026
Merged via the queue into ClickHouse:master with commit a4cd0cf May 15, 2026
162 of 166 checks passed
@scanhex12
scanhex12 deleted the iceberg_field_ids_data_files branch May 15, 2026 12:22
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label May 15, 2026
@scanhex12 scanhex12 added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Aug 24, 2026
@robot-clickhouse robot-clickhouse added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Aug 24, 2026
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Sep 3, 2026
josephperez3 added a commit to josephperez3/ClickHouse that referenced this pull request Nov 2, 2026
…s with field ids

`SELECT arr.u FROM <iceberg table>` with `arr Array(Tuple(u ..., v ...))` returned empty arrays
since ClickHouse#102362 (26.5) when the Parquet data file has field ids, as files written by Spark, Flink,
pyiceberg and ClickHouse itself do. The same held for `deep.s.p`, `aa.u`, `st.x.u` and any other
tuple element reached through a list, also inside WHERE.

ClickHouse#102362 made the Iceberg column mapper name the element of a list `arr.element` (and its fields
`arr.element.u`), which the writer needs. To keep resolving the names of the element's fields in
the Parquet reader, it replaced the reader-side name of the element node with `arr.element`. So
the leaf was named `arr.element.u`, the requested `arr.u` was not found in the file, and it was
filled with defaults.

Keep the reader-side name (`arr.u`, as for files without field ids and in `file()`) and track the
path in the column mapper's names separately, to strip the parent's prefix from the mapped names
of the children.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-improvement Pull request with some product improvements pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IcebergS3: Parquet files written without PARQUET:field_id metadata, breaking Trino column mapping

7 participants