Skip to content

CDC pipelines in writing path from iceberg v3 - #116171

Merged
scanhex12 merged 8 commits into
masterfrom
cdc_for_writing
Sep 10, 2026
Merged

scanhex12 merged 8 commits into
masterfrom
cdc_for_writing

Conversation

@scanhex12

@scanhex12 scanhex12 commented Aug 24, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • New Feature

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

Iceberg v3 has new statistics (next-seq-num and first_row_id). This PR allows to write those stats. Continue of #115603


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

Version info

  • Merged into: 26.9.1.1119 (included in 26.9 and later)

@scanhex12
scanhex12 marked this pull request as draft August 24, 2026 19:16
@clickhouse-gh

clickhouse-gh Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4eac064]

Summary: ❌

job_name test_name status info comment
Stress test (arm_debug) FAIL
Logical error: Input nodes size mismatch in dag: A, expected: [B], [C] (STID: 4752-5ad8) FAIL cidb
Finish Workflow FAIL
python3 ./ci/jobs/scripts/workflow_hooks/feature_docs.py FAIL

AI Review

Summary

This PR teaches the Iceberg writer to emit format-version = 3 manifest and manifest-list metadata for ClickHouse-written tables, and it adds good end-to-end coverage for the plain append cases. I still see one blocker on the upgrade path from externally upgraded v2 tables: the first ClickHouse commit after the upgrade does not assign row IDs to the carried-forward data manifests, so old rows stay without _row_id and the table's row-id budget stays too small.

PR Metadata
  • Changelog category: New Feature is correct for this change.
  • Changelog entry: required for New Feature, but the current text is too implementation-focused and the "Continue of ..." sentence is not user-facing. Suggested replacement: ClickHouse now writes Iceberg format-version 3 row-lineage metadata: first-row-id, next-row-id, and manifest-list first_row_id, enabling CDC and row-lineage pruning for ClickHouse-written Iceberg tables.
Findings

❌ Blockers

  • [src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergWrites.cpp:842-913; src/Storages/ObjectStorage/DataLakes/Iceberg/MetadataGenerator.cpp:256-263] [dismissed by author -- https://github.com/CDC pipelines in writing path from iceberg v3 #116171#discussion_r3967544398] The first ClickHouse commit after an external v2 -> v3 upgrade still copies parent data manifests with first_row_id = null and then advances the snapshot's added-rows / table next-row-id only by newly inserted rows. Iceberg v3 requires post-upgrade snapshots to assign row IDs to both existing and added data files, so the current code leaves pre-upgrade rows with _row_id = NULL and can reuse ID space that should have been reserved for those old files.
    Suggested fix: when copying a format-version = 3 parent manifest-list entry whose content = DATA and first_row_id is null, assign it the current next_first_row_id, advance by at least added_rows_count + existing_rows_count, and include those newly assigned existing rows in the snapshot's added-rows / next-row-id accounting.
Tests
  • ⚠️ Please add a focused regression that starts from a Spark-created format-version = 2 table, upgrades it to format-version = 3, then performs the first ClickHouse append or delete and asserts that the pre-upgrade rows get non-null _row_id values and that next-row-id advances past both the old and new rows.
Final Verdict

Changes requested.

LLVM Coverage Report

Measured on commit 4eac064.

Metric Baseline Current Δ
Lines 88.90% 88.90% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 81.30% 81.30% +0.00%

Changed lines: Changed C/C++ lines covered: 122/148 (82.43%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label Aug 24, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 4eac06466 with master 1401785b7 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 4d7f75efa; 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

9 object files changed (+30.43 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Storages/ObjectStorage/DataLakes/Iceberg/IcebergWrites.cpp.o 948.34 KiB 966.04 KiB +17.70 KiB (+1.87%)

716 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

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

Job report

@clickhouse-gh clickhouse-gh Bot added the comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. label Sep 4, 2026
# Conflicts:
#	src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergWrites.cpp
@scanhex12
scanhex12 marked this pull request as ready for review September 8, 2026 16:29
# Conflicts:
#	src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergWrites.cpp
scanhex12 and others added 2 commits September 9, 2026 15:57
Conflict in `test_row_lineage_pruning.py`: both sides appended tests to the end of the file, and
the surrounding `assert _pruned_files(...)` scaffolding is similar enough that the line-based
merge interleaved hunks from unrelated test functions. Resolved by taking master's version of the
file and re-appending the blocks this branch adds - `INSERT_SETTINGS`,
`_clickhouse_table_with_five_appends` and the three `*_clickhouse` tests - plus the
`create_iceberg_table` import they need. This branch only ever added to that file (161 insertions,
no deletions), so nothing from either side is dropped: all ten tests are present.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Resolving the `test_row_lineage_pruning.py` conflict in the previous commit lost the
`@pytest.mark.parametrize("storage_type", ["s3"])` line above each of the three tests this branch
adds, so all three failed collection with `fixture 'storage_type' not found`.

Both sides only ever added to this file, so the union is fully determined: master's version plus
this branch's own additions. Rebuilt it that way from the diff hunks instead of by matching
top-level definitions, which is what separated the decorators from their functions. The file is
now exactly 161 lines ahead of master and 193 ahead of the branch, with no deletions on either
side.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@scanhex12
scanhex12 enabled auto-merge September 10, 2026 10:22
@scanhex12
scanhex12 added this pull request to the merge queue Sep 10, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 40 queries analysed

no significant changes detected. K_source=6 K_base=30 flagged=0/65

clickbench

🟢 No significant changes

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 3202e491-74bd-4a67-86af-6e4c924d5f53
  • MIRAI run: cde8fa2a-4173-4eb5-b94a-d51af71b4c8a
  • PR check IDs:
    • clickbench_19581_1789035014
    • clickbench_19587_1789035013
    • clickbench_19593_1789035014
    • tpch_adapted_1_official_19606_1789035013
    • tpch_adapted_1_official_19638_1789035014
    • tpch_adapted_1_official_19652_1789035014

Merged via the queue into master with commit 2d7cd1b Sep 10, 2026
171 of 174 checks passed
@scanhex12
scanhex12 deleted the cdc_for_writing branch September 10, 2026 10:43
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 10, 2026
@clickgapai

Copy link
Copy Markdown
Contributor

@scanhex12 — ClickGap found the following in this PR:

Close anything that's wrong or already addressed.

@subkanthi subkanthi mentioned this pull request Sep 16, 2026
11 of 17 tasks
zvonand added a commit to Altinity/ClickHouse that referenced this pull request Oct 22, 2026
…-writes

Antalya 26.6: Backport of ClickHouse#116171 to write iceberg v3 next_seq_num and first_row_id
@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-feature Pull request with new product feature 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.

4 participants