Skip to content

Fix the byte width of Iceberg manifest bounds for int and date columns - #117571

Merged
PedroTadim merged 7 commits into
ClickHouse:masterfrom
groeneai:fix-117072-iceberg-int-date-bound-width
Sep 3, 2026
Merged

PedroTadim merged 7 commits into
ClickHouse:masterfrom
groeneai:fix-117072-iceberg-int-date-bound-width

Conversation

@groeneai

@groeneai groeneai commented Sep 1, 2026 •

Copy link
Copy Markdown
Collaborator

Closes: #117072

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 the byte width of the Iceberg manifest lower_bounds and upper_bounds written for int and date columns: they were 8 bytes wide where the Iceberg specification requires 4. Spec-conformant readers such as pyiceberg failed with unpack requires a buffer of 4 bytes while planning any scan carrying a filter on such a column.

Description

ClickHouse wrote the Iceberg manifest lower_bounds and upper_bounds of int and date
columns as 8 bytes, where Appendix D of the Iceberg specification requires 4. ClickHouse's own
reader takes only the leading sizeof(type) bytes, so ClickHouse round trips pass; pyiceberg
parses at the spec width and aborts scan planning with unpack requires a buffer of 4 bytes.

dumpValue takes its width from sizeof(T), with T deduced from its argument, and
Field::safeGet<Int32> returns NearestFieldType<Int32>, which is Int64, so the branch asked for
Int32 and got 8 bytes. Date reaches the same branch through the UInt64/Int64 allowance in
Field::safeGet. The fix narrows before dumping, the same static_cast<Int32> idiom the
neighbouring small-integer branch already uses. The same line corrects the manifest-list
partition summary OPTIMIZE ... MANIFEST writes for an int or date partition column.

A new integration test writes the table with ClickHouse and scans it with pyiceberg 0.11.1: the
int and date bounds go from 2A00000000000000 and A34D000000000000 to 2A000000 and
A34D0000, filters on Int32, Date and Date32 return the row, and filters outside them return
nothing, with Int64, String and unfiltered scans as controls. It fails on a pristine master
binary. The previous coverage decoded with reinterpretAsInt32, which reads its own width and
cannot see it.

No reader change or format version is needed: ColumnVector::insertData ignores the buffer length,
so an existing 8-byte bound still decodes, and 4 bytes is at least sizeof(type) for all three
carriers. Manifests written earlier keep their 8-byte bounds: they are immutable, and a
manifest-only rewrite copies the bytes verbatim, so an existing table is corrected only as its data
files are rewritten.

Float32 bounds carry the same latent defect, but canDumpIcebergStats rejects Float32 at both
call sites, so no input reaches it; I left it unchanged rather than ship a change no test can back.


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

Version info

  • Merged into: 26.9.1.637 (included in 26.9 and later)
  • Backported to: 26.8.5.12, 26.7.9.13, 26.6.7.20, 26.3.33.87

`ClickHouse` wrote the Iceberg manifest `lower_bounds` and `upper_bounds` of
`int` and `date` columns as 8 bytes, where Appendix D of the Iceberg
specification requires 4. `dumpValue` sizes its output as `sizeof(T)` with `T`
deduced from its argument, and `Field::safeGet<Int32>` returns
`NearestFieldType<Int32>`, which is `Int64`, so the branch asked for an `Int32`
and got an 8-byte value. `Date` is `UInt16` internally and therefore
`UInt64`-tagged; it reaches the same branch because `Field::safeGet` explicitly
permits the `UInt64`/`Int64` pair, reinterpreting the same 8-byte slot.
`Date32` is `Int32`-backed and so behaves exactly like `Int32`.

Narrow the value before `dumpValue` sees it, with the same `static_cast<Int32>`
the neighbouring small-integer branch already uses for types that map to the
same Iceberg `int`.

The `ClickHouse` and Java readers consume only the leading `sizeof(type)` bytes,
so `ClickHouse`-only round trips passed and hid this. `pyiceberg` parses at the
spec width and aborts scan planning with `unpack requires a buffer of 4 bytes`
for any filter on such a column, while an unfiltered scan succeeds because it
never consults bounds. Verified with `pyiceberg` 0.11.1: the reported failure
reproduces before this change and both filters scan cleanly after.

The same line also corrects the manifest-list partition summary written by
`OPTIMIZE ... MANIFEST` for an `int` or `date` partition column
(`0700000000000000` to `07000000`, verified by hand).

No reader change and no format version are needed in either direction:
`ColumnVector::insertData` ignores the buffer length and does
`unalignedLoad<T>(pos)`, so an existing 8-byte bound still decodes, and a
4-byte bound is at least `sizeof(type)` for all three carriers. Measured across
{old, new binary} x {8-byte, 4-byte table}: identical correct results.

The existing bounds coverage could not catch this because it decodes with
`reinterpretAsInt32`, which reads its own width and returns the right value from
a bound of any length. The new test asserts the raw bytes instead, and carries an
`Int64` and a `String` bound in the same manifest as controls.

`Float32` bounds have the same latent defect, but `canDumpIcebergStats` rejects
`Float32` at both call sites, so no input reaches it; left unchanged rather than
shipping a change no test can back.

Closes: ClickHouse#117072
The fixture pinned the width of the narrowed write but not its sign. Every bound
in it was non-negative, and for a non-negative value that fits in 32 bits
`static_cast<Int32>` of the `Field`'s `Int64` slot is value-preserving identity,
so nothing in the test would have noticed a narrowing that mishandled the sign.
`Date32` is the only type in the changed `case` label able to supply a negative
bound, because `Date` is `UInt16`-backed and cannot be negative.

Append `d32 Date32` as the last column, which leaves field ids 1 to 4 and their
expected bytes unchanged. Measured on both arms: `toDate32('1950-01-01')` is day
-7305 and is written as `77E3FFFF` with the fix, and as the sign-extended
`77E3FFFFFFFFFFFF` without it. All five field ids are present in both bound
arrays, which is what shows the added column was accepted rather than silently
emptying the statistics, since `canWriteStatistics` is all or nothing across an
entry's columns.
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Sep 1, 2026
@groeneai

groeneai commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex). Two passes: a full pass, which raised
the finding below, then a delta recheck after the fix round, which returned no findings.

# Sev Finding Verdict Evidence / action
1a ⚠️ The test proves the width for Int32 and Date but not for Date32, the third type the narrowed expression serves AGREE, fixed in the fix round Sharpened while adjudicating: every bound in the original fixture was non-negative, and for such a value the narrowing cast is value-preserving identity, so the fixture pinned the width and never the sign. Only Date32 can carry a negative bound here, since Date is UInt16-backed. The fixture now also holds a pre-epoch Date32, and reverting only the cast widens that row too
1b ⚠️ The test does not cover the manifest-list partition summary written by OPTIMIZE ... MANIFEST DISAGREE Both call sites reach the same single expression, so a width regression in the changed line is already caught by the data-file scenario; the summary would only escape if the caller stopped routing through dumpFieldToBytes, which this change does not touch. I measured that surface directly instead: on PARTITION BY p with p Int32 = 7, partitions[].lower_bound and upper_bound go from 0700000000000000 to 07000000. Freezing it into CI needs the manifest list resolved from current-snapshot-id, because a filename sort silently reads the pre-OPTIMIZE list and reports an empty array, so the naive form of that test asserts nothing
2 💡 The description gave only the read half of the compatibility story AGREE, fixed in the description Manifests already written keep their 8-byte bounds: they are immutable, and a manifest-only rewrite copies bound bytes over verbatim, so an existing table is corrected only as its data files are rewritten. Stated in the description so the fix is not read as retroactive

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding. Findings on hunks unchanged by the fix round are auto-dropped.

@clickhouse-gh clickhouse-gh Bot closed this Sep 1, 2026
@clickhouse-gh clickhouse-gh Bot reopened this Sep 1, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [3515fd9]

Summary: ✅


AI Review

Summary

This PR fixes the 8-byte Field narrowing bug for Iceberg manifest int/date bounds and replaces the old stateless check with a much better pyiceberg interoperability regression test. The little-endian path now looks correct, but I would not approve the change as-is because the same write path still serializes numeric bounds in host byte order, so the contract this PR is tightening remains broken on big-endian builds.

Findings

❌ Blockers

  • [src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergWrites.cpp:267] [dismissed by author -- https://github.com/Fix the byte width of Iceberg manifest bounds for int and date columns #117571#discussion_r3907790665] This branch now narrows the bound to 4 bytes, but it still feeds dumpValue, which is a raw host-endian memcpy. On a big-endian build that writes 42 as 00 00 00 2A, while Iceberg Appendix D requires little-endian 2A 00 00 00; a spec reader therefore decodes the bound as 704643072. That turns the current loud interoperability failure into silent wrong pruning for filters such as i32 <= 100, so the bug is still real on the architecture where ClickHouse builds s390x artifacts. Suggested fix: introduce explicit little-endian Iceberg numeric bound encode/decode helpers and use them on both the write path here and the symmetric read path in ManifestFileIterator, or reject Iceberg writes on big-endian targets until that support exists.
Final Verdict

Changes are headed in the right direction and the new interoperability test is valuable, but the fix is incomplete: int/date bounds are still not serialized in Iceberg wire order on big-endian builds. I would keep this PR blocked until that remaining cross-endian correctness gap is addressed or explicitly unsupported.

LLVM Coverage Report

Measured on commit 3515fd9.

Metric Baseline Current Δ
Lines 88.70% 88.70% +0.00%
Functions 92.10% 92.10% +0.00%
Branches 81.00% 81.00% +0.00%

Changed lines: Changed C/C++ lines covered: 6/7 (85.71%) · Uncovered code

Full report · Diff report

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

groeneai commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, 100%. CREATE TABLE t (i32 Int32, d Date, i64 Int64, s String, d32 Date32) ENGINE = IcebergLocal(...,'Parquet') + one INSERT, then read the manifest: SELECT arraySort(arrayMap(x -> (x.1, hex(x.2)), tupleElement(data_file, 'lower_bounds'))) FROM file('<manifest>', Avro). Emits 2A00000000000000 and A34D000000000000, byte-for-byte the two values in the issue. Shipped as 05055_iceberg_manifest_bound_width_117072.
b Root cause explained? Yes. dumpValue sizes its output as sizeof(T) with T deduced from the argument; Field::safeGet<Int32> returns NearestFieldType<Int32>, which is Int64 (Core/Field.h), so the branch instantiates T = Int64 and writes 8 bytes where the Iceberg spec wants 4. A compile-time fact, not a runtime Field-tag inference. Date (internally UInt16, so UInt64-tagged) passes safeGet<Int32> only via the explicit UInt64/Int64 allowance in Field::safeGet, then takes the same 8-byte path.
c Fix matches root cause? Yes. It narrows the value at the point where the width is decided, using the same static_cast<Int32> idiom the neighbouring small-integer branch already uses. No guard, no reader-side tolerance, no widened assertion: +2/-1 in src/.
d Test intent preserved / new tests added? New test added; no existing test weakened or edited. The oracle asserts raw hex bytes, because the existing bounds coverage decodes with reinterpretAsInt32, which reads its own width and so asserts the value while being blind to the width. The fixture carries a pre-epoch Date32 bound, so it pins the sign of the narrowed write as well as its width: with only non-negative bounds the cast is value-preserving identity and the sign would be untested. 04652_iceberg_insert_per_file_statistics is deliberately untouched and its .reference is byte-identical after the change (verified).
e Both directions demonstrated? Yes, on Build-ID-verified binaries. Base b62a15e1f3c805df401de7c8257f1854c8945e54: test FAILS, and element-wise exactly the three fields the changed expression serves flip (i32, d, d32), while the Int64 and String controls are byte-identical. With the fix: PASSES, 100/100 over two 50-run arms (randomized settings on, and --no-random-settings --no-random-merge-tree-settings). Base differs from the fix only by that one hunk, and a comment cannot change bytes, so this isolates the static_cast. A separate mutation arm (revert only the static_cast, rebuild to 1d87a7467a4f0a0dc0656e84d6ccb41faa75b332) independently reddened the i32 and d rows and no others.
f Fix is general across code paths? Yes. dumpFieldToBytes has exactly two call sites plus its own Nullable recursion, and one change covers both: data-file bounds (reached from INSERT, mutations and OPTIMIZE) and the manifest-list partition summary. The second surface was verified by hand on a PARTITION BY an Int32 column: OPTIMIZE ... MANIFEST wrote 0700000000000000 before and 07000000 after. No second Iceberg writer exists.
g Fix generalizes across inputs? Yes, across the reachable surface. canDumpIcebergStats gates both call sites and admits only Nullable(nested), Int32, Date, Date32, Int64, DateTime64, String and Decimal32/64/128/256, so the small-integer, UInt64 and both float branches take no user input. All three carriers of the fixed branch are representable in 4 bytes by construction (Int32; Date = UInt16; Date32 = Int32), so the narrowing cannot truncate, and all three are covered by the fixture. Both value classes are covered too: a positive bound, where the cast is identity, and a negative one (toDate32('1950-01-01'), day -7305, 77E3FFFF narrowed from the sign-extended 77E3FFFFFFFFFFFF). Int64 (8 bytes) and String (variable) ride in the same manifest as controls and are byte-identical across both arms. Float32 has the same latent defect but is unreachable, and is disclosed in the description rather than changed.
h Backward compatible? Yes, both directions, no format version and no SettingsChangesHistory.cpp entry. deserializeFieldFromBinaryRepr reads bounds via ColumnVector<T>::insertData, which ignores the length and does unalignedLoad<T>(pos): an existing 8-byte bound still decodes correctly, and a new 4-byte bound is at least sizeof(T) for all three carriers, so it is not an over-read. Measured, not argued: 4 of 4 cells of {old, new binary} x {8-byte, 4-byte table} return identical correct rows for filtered and unfiltered reads. The strongest evidence is that the reader already consumes spec-width 4-byte bounds from every Spark-written table.
i Invariants and contracts preserved? Yes. The change is confined to one case of a static helper in an anonymous namespace in a single translation unit; no lifetime, locking, ownership or error path is touched, and no caller signature changes. The verbatim-carryover branch that copies pre-serialized bytes from a source manifest during a rewrite stays byte-preserving. The invariant it restores is the Iceberg one: a single-value binary bound is exactly as wide as its Iceberg type. Full *iceberg* stateless sweep A/B'd against the base binary: identical failure sets except the new test, i.e. zero regressions (the 20 shared failures are Code: 669 There is no named collection s3_conn, absent in this sandbox, and fail identically on pristine master).

Session id: cron:clickhouse-impl-slot-41:20260901-175600

return dumpValue(field.safeGet<Int32>());
/// Iceberg writes `int` and `date` as 4 bytes, while a `Field` keeps them in its 8-byte
/// slot; `dumpValue` takes the width from its argument type, so narrow before dumping.
return dumpValue(static_cast<Int32>(field.safeGet<Int32>()));

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.

static_cast<Int32> fixes the width, but this still goes through dumpValue, which is a raw memcpy of the host representation. On s390x that makes this path write 0000002A here instead of Iceberg's required little-endian 2A000000, so ClickHouse-written manifest bounds remain non-conformant on a supported big-endian target and the new test is only correct on little-endian hosts. Please serialize Iceberg numeric bounds explicitly in little-endian instead of relying on native endianness.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Agreed on the mechanism, and out of scope for this PR.

dumpValue has been a host-representation memcpy since 4b551c7f8016131 (2025-08-20), and the line before my change was dumpValue(field.safeGet<Int32>()), which is the same host-endian write at 8 bytes. My change narrows the width, not the byte order.

Fixing only this branch would not help s390x anyway. canDumpIcebergStats (IcebergWrites.cpp:130-140) also admits Int64 and DateTime64, which reach the same dumpValue at :269 and :279, so the reported table's long and timestamp bounds stay reversed either way. On a big-endian host neither form is conformant: today pyiceberg fails on the width, with a little-endian writer it would read a reversed 4-byte value.

The writer-only remedy would also make big-endian worse. The read path is symmetric: ManifestFileIterator.cpp:130-132 states that the binary representation "matches our internal representation" and calls insertData, which is a host-endian unalignedLoad<T> (ColumnVector.h:85-88). A little-endian writer against that reader means ClickHouse on s390x misreads the bounds it wrote itself and prunes its own files wrongly. Only the decimal branches are explicit about byte order today (:195-196 and deserializeDecimalBound), so both sides have to move together. I will not do that blind: the s390x build is compile-only (ENABLE_TESTS=0, ci/jobs/build_clickhouse.py:46) and CH_S390X is only produced, never required by a test job, so no big-endian target runs any test and I have no big-endian host to measure on.

The new test's hex assertions do hold on little-endian only, as you say. So does 04652_iceberg_insert_per_file_statistics.sh next to it, which decodes the same bounds with reinterpretAsInt32 and records that assumption in its own comment. With no big-endian test job to gate on, I am not adding a guard for a configuration nothing runs.

@clickhouse-gh

clickhouse-gh Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 3515fd9ef with master 0ee60bc06 (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

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

Job report

@groeneai

groeneai commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - f4e5bf3

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
Bugfix validation (functional tests, amd64) functional_tests.py:734 assert build_urls, "Could not find master builds in S3" - the master-build S3 lookup missed the new artifact prefix #117580 (external, merged 2026-09-01T22:06:23Z), absent from this build (rule 3c)
Bugfix validation (functional tests, aarch64) same assertion, sibling arch #117580 (external, merged 2026-09-01T22:06:23Z), absent from this build (rule 3c)
Finish Workflow / new_tests_check.py downstream of the two rows above: the hook reports Bugfix validation as seen by this check: ... ERROR and fails on it #117580 (external, merged 2026-09-01T22:06:23Z), absent from this build (rule 3c)
Integration tests (amd_asan_ubsan, db disk, old analyzer, 6/6) / Container memory budget exceeded (/docker) nested-container OOM (oom_memcg=/docker/<dind>/docker, task=clickhouse/gdb); every test in the shard reported OK #117564 (mine, open)

Bugfix validation (functional tests, *) and Finish Workflow share one cause: #117580
changes find_master_builds in ci/jobs/scripts/bugfix_validation.py, which functional_tests.py
consumes. Fix-presence probed at the failing tree rather than inferred from timing: pre-fix
695469d13cd1 = 0, at the fix 41b739a45086 = 1, this head f4e5bf3bd10a = 0.

I have deliberately NOT merged master to pick #117580 up yet. Both remaining gating rows would
have to clear together, and the /docker row's owner is my own still-open #117564, so a re-run
now would swap one red for another at the cost of a full cycle and a workflow approval. I will
merge master once #117564 lands.

Stateless tests (amd_debug, flaky check) is NOT listed: it errored on its first attempt and
passed on its second (20:49:08 error -> 20:53:41 success), and the leaf artifact records it OK.

Session id: cron:our-pr-ci-monitor:20260902-013000

@PedroTadim PedroTadim self-assigned this Sep 2, 2026
rm -rf "${BOUND_PATH}"

# One row, so there is exactly one data file and one manifest whatever the randomized block sizes are.
${CLICKHOUSE_CLIENT} --query "

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@groeneai is it possible to change this into an integration test and show PyIceberg can read Int32 and Date32 columns?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done in 67cfc6b. The stateless test is deleted and the coverage is now test_ch_write_pyiceberg_read_bound_width in tests/integration/test_storage_iceberg_interoperability_local/test_interoperability.py: ClickHouse creates the table and inserts one row, then pyiceberg 0.11.1 opens it with StaticTable.from_metadata and scans it. I picked that package because its external_dirs mount already gives the server and the test process one absolute path for the table, so pyiceberg reads exactly what ClickHouse wrote, the way the reporter did.

What it shows:

  • filters on i32 Int32, d Date and d32 Date32 each return the row, and filters outside the bounds return nothing, so the narrowed bounds are usable and not only parseable;
  • Int64, String and an unfiltered scan are controls, since those worked before the fix too;
  • the raw lower_bounds and upper_bounds are still asserted per field id, which keeps the width, the value, the byte order and the sign of the pre-epoch Date32 pinned.

Both arms measured in the integration harness. With the fix it passes. Against a pristine master binary it fails on the bound bytes (2A00000000000000, A34D000000000000, 77E3FFFFFFFFFFFF, while the long and string bounds are identical), and the three filtered scans raise unpack requires a buffer of 4 bytes.

groeneai and others added 2 commits September 2, 2026 09:55
Issue ClickHouse#117072 is about an external reader: `pyiceberg` cannot plan a filtered
scan of a `ClickHouse`-written table whose `int` or `date` bound is 8 bytes wide.
A stateless test can assert the bytes in the manifest, but nothing in
`0_stateless` can show that `pyiceberg` then accepts them, which is the property
the fix exists for.

Replace `05055_iceberg_manifest_bound_width_117072` with
`test_ch_write_pyiceberg_read_bound_width` in the local interoperability suite.
That package already mounts the table at one absolute path for both
`ClickHouse` (container) and the test process (host) through `external_dirs`, so
`pyiceberg` opens exactly what `ClickHouse` wrote, the way the reporter did with
`StaticTable.from_metadata`.

The byte-level oracle is kept rather than traded away: the test reads the raw
`lower_bounds` and `upper_bounds` per field id, which pins width, value, byte
order, and the sign of the pre-epoch `Date32`. On top of that it asserts what the
stateless test could not reach: filters on `Int32`, `Date` and `Date32` return
the row, filters outside the bounds return nothing, and the `Int64`, `String` and
unfiltered cases stay green because they were never affected.

Measured on both arms in the integration harness. With the fix the test passes;
against a pristine master binary it fails on the bound bytes
(`2A00000000000000`, `A34D000000000000`, `77E3FFFFFFFFFFFF` instead of
`2A000000`, `A34D0000`, `77E3FFFF`) while the `long` and `string` bounds are
identical, and the three filtered scans raise
`unpack requires a buffer of 4 bytes`.

Requested by PedroTadim while reviewing ClickHouse#117571.
@groeneai

groeneai commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - f9db59d

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
Parser memory check / Resolve master binary master-side, not this diff: praktika's static S3 prefix gained an unconditional workflow-name segment in #110081, so this job's hand-spelled baseline key REFs/master/<sha>/build_arm_release/clickhouse-examples 403s on every tracked commit and the step errors No master clickhouse-examples artifact was found. 152 distinct pull requests carry it since 2026-09-02 10:14:18Z, 0 true-master runs #117701 (mine, merged 2026-09-02T16:49:23Z). This tree predates the merge, so the red is expected here; the master merge that picks it up is deferred to avoid a rebuild that cannot turn the head green yet
LLVM Coverage / Generate LLVM Coverage Diff Report, then Print Uncovered Code as its cascade master-side, not this diff: the same #110081 prefix change orphaned the hand-spelled coverage baseline key, so the 100-commit baseline walk finds nothing and the uncovered-code step never runs. 58 distinct pull requests carry it since 2026-09-02 13:07:52Z, 0 true-master runs #117718 (external, open)

Session id: cron:our-pr-ci-monitor:20260902-193000

@PedroTadim
PedroTadim enabled auto-merge September 3, 2026 08:09
… interop test

The manifest bound width test opened a table's newest `metadata/vN.metadata.json`
by comparing `last-updated-ms`. `CREATE TABLE` and the first `INSERT` each stamp
that field from `system_clock::now()` truncated to milliseconds (`Utils.cpp:1063`
and `MetadataGenerator.cpp:216`), so the two documents can carry the same value.
Python's `max` returns the first maximal element and `glob.glob` lists `v1` before
`v2`, so on a tie the helper returned the pre-INSERT document, whose
`current-snapshot-id` is -1, and the next line raised `AttributeError` on a `None`
snapshot instead of reading the manifest.

Ordering by `N` takes the timestamp out of the decision. It also agrees with how
ClickHouse resolves the table itself: `iceberg_recent_metadata_file_by_last_updated_ms_field`
defaults to false, which selects `BY_METADATA_FILE_VERSION` (`Utils.cpp:1189`).
`test_manifest_compaction.py` tie-breaks on the same parsed version, and
`test_full_path_scheme.py` in this package orders by it too.

Measured: 40 of 40 `CREATE TABLE` plus `INSERT` pairs left a gap of 4 ms or more,
so no tie was observed on this fixture. With the tie forced, the previous helper
selected `v1.metadata.json` and this one selects `v2.metadata.json`; both select
`v2.metadata.json` when the timestamps differ.
auto-merge was automatically disabled September 3, 2026 15:01

Head branch was pushed to by a user without write access

@PedroTadim
PedroTadim enabled auto-merge September 3, 2026 15:25
@PedroTadim
PedroTadim added this pull request to the merge queue Sep 3, 2026
Merged via the queue into ClickHouse:master with commit 6113efb Sep 3, 2026
175 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 3, 2026
alexey-milovidov added a commit that referenced this pull request Sep 13, 2026
`test_writes_manifest_list_partition_summary` asserts the raw bytes
of the manifest-list partition summary, and it is the first test to do
so, which is why it fails on this branch for every parametrisation
while it is green on master:

  At index 1 diff: (False, None, b'\x0b\x00\x00\x00\x00\x00\x00\x00', ...) != (False, None, b'\x0b\x00\x00\x00', ...)

The `Int32` partition bound is written as 8 bytes where Appendix D of
the Iceberg specification requires 4. `dumpValue` sizes its output as
`sizeof(T)` with `T` deduced from its argument, and
`Field::safeGet<Int32>` returns `NearestFieldType<Int32>`, which is
`Int64`, so the branch asks for an `Int32` and gets an 8-byte value.

Narrow before `dumpValue` sees it, with the same `static_cast<Int32>`
the neighbouring small-integer branch already uses. This is the source
half of `3dc6b4f4ef32` (#117571, `Closes #117072`), which never got a
backport label; this branch needs it because the test it adds pins the
spec width. That test is the coverage here, so the stateless test of
the original commit is left out rather than duplicated.

The data-file bounds are corrected by the same line, so this branch
stops writing manifests that `pyiceberg` refuses to plan a filtered
scan over (`unpack requires a buffer of 4 bytes`). No reader change is
needed in either direction: `ColumnVector::insertData` ignores the
buffer length and does `unalignedLoad<T>(pos)`, so an existing 8-byte
bound still decodes.

Related: #117571
Related: #117072
alexey-milovidov added a commit that referenced this pull request Sep 13, 2026
`test_writes_manifest_list_partition_summary` asserts the raw bytes
of the manifest-list partition summary, and it is the first test to do
so, which is why it fails on this branch for every parametrisation
while it is green on master:

  At index 1 diff: (False, None, b'\x0b\x00\x00\x00\x00\x00\x00\x00', ...) != (False, None, b'\x0b\x00\x00\x00', ...)

The `Int32` partition bound is written as 8 bytes where Appendix D of
the Iceberg specification requires 4. `dumpValue` sizes its output as
`sizeof(T)` with `T` deduced from its argument, and
`Field::safeGet<Int32>` returns `NearestFieldType<Int32>`, which is
`Int64`, so the branch asks for an `Int32` and gets an 8-byte value.

Narrow before `dumpValue` sees it, with the same `static_cast<Int32>`
the neighbouring small-integer branch already uses. This is the source
half of `3dc6b4f4ef32` (#117571, `Closes #117072`), which never got a
backport label; this branch needs it because the test it adds pins the
spec width. That test is the coverage here, so the stateless test of
the original commit is left out rather than duplicated.

The data-file bounds are corrected by the same line, so this branch
stops writing manifests that `pyiceberg` refuses to plan a filtered
scan over (`unpack requires a buffer of 4 bytes`). No reader change is
needed in either direction: `ColumnVector::insertData` ignores the
buffer length and does `unalignedLoad<T>(pos)`, so an existing 8-byte
bound still decodes.

Related: #117571
Related: #117072
@PedroTadim

Copy link
Copy Markdown
Member

Backporting to merge these backports #118796

@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Sep 15, 2026
robot-clickhouse added a commit that referenced this pull request Sep 15, 2026
Cherry pick #117571 to 26.6: Fix the byte width of Iceberg manifest bounds for `int` and `date` columns
PedroTadim added a commit that referenced this pull request Sep 15, 2026
Both conflicts are master-only changes around the PR, not divergence in the fix.
Master moved ICEBERG_DIR_* onto a new iceberg_local_interop_dir() helper, and
appended test_spark_gzip_metadata_ch_write_spark_read (issue #109801, a different
PR) just before this PR's additions. Kept 26.6's own import line and dropped the
gzip test; the 100 added lines are byte-identical to the original.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
robot-clickhouse added a commit that referenced this pull request Sep 15, 2026
PedroTadim added a commit that referenced this pull request Sep 15, 2026
Cherry pick #117571 to 26.3: Fix the byte width of Iceberg manifest bounds for `int` and `date` columns
robot-clickhouse added a commit that referenced this pull request Sep 15, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Sep 15, 2026
clickhouse-gh Bot pushed a commit that referenced this pull request Sep 15, 2026
clickhouse-gh Bot added a commit that referenced this pull request Sep 15, 2026
Backport #117571 to 26.7: Fix the byte width of Iceberg manifest bounds for `int` and `date` columns
clickhouse-gh Bot pushed a commit that referenced this pull request Sep 15, 2026
clickhouse-gh Bot added a commit that referenced this pull request Sep 15, 2026
Backport #117571 to 26.8: Fix the byte width of Iceberg manifest bounds for `int` and `date` columns
clickhouse-gh Bot added a commit that referenced this pull request Sep 15, 2026
Backport #117571 to 26.6: Fix the byte width of Iceberg manifest bounds for `int` and `date` columns
PedroTadim added a commit that referenced this pull request Sep 15, 2026
Backport #117571 to 26.3: Fix the byte width of Iceberg manifest bounds for `int` and `date` columns
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 groeneai-origin-request PR origin: a maintainer pinged or directed groeneai pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default 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 v26.3-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Iceberg: manifest bounds for int and date columns are written as 8 bytes (spec: 4) — every filtered pyiceberg scan of a ClickHouse-written table fails

4 participants