Skip to content

Write split_offsets of Parquet data files to Iceberg manifests - #125619

Merged
scanhex12 merged 4 commits into
masterfrom
iceberg-write-split-offsets
Oct 24, 2026
Merged

scanhex12 merged 4 commits into
masterfrom
iceberg-write-split-offsets

Conversation

@scanhex12

@scanhex12 scanhex12 commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

The Iceberg writer left data_file.split_offsets empty, so readers (ClickHouse bucket splitting, Trino, Spark) had to read the Parquet footer to split a file on row group boundaries. The Parquet output format now reports the file_offset of the row groups it wrote, and the manifest entry of every data file written by INSERT stores them.

Part 4: #124890

Changelog category (leave one):

  • Improvement

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

Write split_offsets of Parquet data files to Iceberg manifests


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

Version info

  • Merged into: 26.11.1.738-master (included in 26.11 and later)

The Iceberg writer left `data_file.split_offsets` empty, so readers (ClickHouse
bucket splitting, Trino, Spark) had to read the Parquet footer to split a file
on row group boundaries. The Parquet output format now reports the
`file_offset` of the row groups it wrote, and the manifest entry of every data
file written by `INSERT` stores them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [6962e76]

Summary: ✅


AI Review

Summary

The PR exports Parquet row group offsets and writes them into Iceberg manifests for INSERT. Review of head 6962e76a72a7b1016880bdb4c86a5d2c2233eae0 retains one unresolved major: metadata-only manifest compaction discards the newly populated offsets. Request changes to preserve them through that lifecycle transition.

Findings

⚠️ Majors

  • src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergWrites.cpp:688: Manifest rewrites discard offsets for unchanged data files. After multiple inserts, OPTIMIZE TABLE … MANIFEST rebuilds their entries through Compaction.cpp using per_file_statistics, without per_file_fresh_statistics. The new condition therefore leaves split_offsets null. Neither ParsedManifestFileEntry nor DataFileColumnStatistics carries the source offsets, so removing the condition alone cannot preserve them. Readers lose the split-planning metadata even though the Parquet files are unchanged. Carry the offsets through manifest parsing and the per-file rewrite metadata, then serialize them for rewritten entries. The field is optional in the Iceberg specification; the impact is lost scan-planning information. This remains covered by the existing open review thread, so no duplicate inline comment was posted.
Tests
  • ⚠️ The added tests inspect fresh files only. Add a stateless regression with two inserts producing multiple row groups, force OPTIMIZE TABLE … MANIFEST, and verify that every live file retains exactly its original split_offsets in the consolidated manifest.
Final Verdict

Status: ⚠️ Request changes. Preserve per-file split_offsets through metadata-only manifest compaction and add the focused regression above.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Oct 13, 2026
ClickHouse-written `split_offsets`, as Spark reads them from the `files`
metadata table, must be the starting positions of the row groups by the rule
of `iceberg-java` (the dictionary page or the first data page of the first
column). For a file written by Spark, ClickHouse must see the same row group
offsets that Spark stored in the manifest.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added the comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. label Oct 13, 2026

if (per_file_fresh_statistics && effective_statistics && !effective_statistics->getSplitOffsets().empty()
&& data_file.hasField(Iceberg::f_split_offsets))
{

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 condition only emits split_offsets for callers that pass per_file_fresh_statistics, i.e. the fresh INSERT path.

The other manifest-generation paths still go through different carriers and will silently lose the field:

  • Compaction.cpp rebuilds manifests from per_file_statistics, but DataFileColumnStatistics has no split_offsets member.
  • Mutations.cpp writes one-file manifests from data_file_statistics and never passes per_file_fresh_statistics here.

So a file written by this PR drops back to split_offsets = null as soon as ClickHouse rewrites its manifest, and update-generated Parquet data files never get the new metadata. Can we thread split_offsets through those paths before landing this?

- Iceberg tables no longer accept `UInt64` columns; use `Int64` in `05395`.
- `DataFile.splitOffsets` of `iceberg-java` returns null when the last offset is not
  less than the file size, and a projection of the `files` metadata table without
  `file_size_in_bytes` leaves the size at 0, so Spark showed no offsets. Select
  `file_size_in_bytes` as well.
- The local uploader passes a file in the arguments of `docker exec`; make the file
  written by Spark small enough for it.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125619&sha=225d04a7e94bda552913c9eace3b492532ce8893&name_0=PR
PR: #125619

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 6962e76a7 with master 00b79c605 (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.

Compile time of recompiled translation units

133 translation units recompiled, 959 s compile time in total, 133 of them have a recent master baseline.

Job report

`05395_iceberg_write_split_offsets` hardcoded 10 row groups, but the Parquet
writer forms row groups from incoming chunks, so a randomized `max_block_size`
(e.g. 8072) produces 9. Check that there are several row groups and that
`split_offsets` match their offsets instead.

`test_spark_split_offsets_match_clickhouse_row_groups` queried the `files`
metadata table as `<table>.files`, which Spark resolves as a table `files` in
a database named after the table. Qualify it as `spark_catalog.default.<table>.files`.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125619&sha=latest&name_0=PR
PR: #125619

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@scanhex12
scanhex12 added this pull request to the merge queue Oct 24, 2026
Merged via the queue into master with commit 8e3eb7a Oct 24, 2026
178 checks passed
@scanhex12
scanhex12 deleted the iceberg-write-split-offsets branch October 24, 2026 19:56
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 24, 2026
@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 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... pr-improvement Pull request with some product improvements 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.

3 participants