Skip to content

Read Iceberg time columns of Parquet data files as microseconds - #126079

Merged
alexey-milovidov merged 3 commits into
ClickHouse:masterfrom
groeneai:groeneai/fix-118807-iceberg-time-parquet-micros
Oct 16, 2026
Merged

alexey-milovidov merged 3 commits into
ClickHouse:masterfrom
groeneai:groeneai/fix-118807-iceberg-time-parquet-micros

Conversation

@groeneai

@groeneai groeneai commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Closes: #118807
Closes: #88063
Related: #105540

Changelog category (leave one):

  • Backward Incompatible Change

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

Iceberg time columns read from Parquet data files are now returned as microseconds since midnight, as documented, instead of whole seconds. The value now agrees with the manifest statistics and partition values, so WHERE on such a column no longer misses rows and the unit no longer depends on the partition spec. Closes #118807. Closes #88063.

Description

On 26.8.18.2, for an Iceberg table written by pyiceberg with a time column t (the script in #118807), SELECT t shows 5400 for 01:30:00.25, but WHERE t = 5400 returns no rows with default settings (also on 26.3.42.3), and the same data in a table partitioned by identity(t) shows 5400250000.

Root cause: ClickHouse maps Iceberg time to Int64 microseconds (the documented mapping), and the manifest bounds, partition values, bucket transform and ORC/Avro data files all carry that number. Only the Parquet reader decoded the TIME(MICROS) column as Time64(6) and then cast it to Int64, i.e. to seconds. So min/max pruning compared a seconds literal with microsecond bounds, and an identity partition substituted microseconds for the seconds of the file.

Change: the Iceberg column mapper carries the field ids of time columns, and the Parquet reader decodes such a column requested as Int64 as the plain stored integer, statistics and bloom filters included. Plain Parquet reads are unchanged. The Iceberg reads that had no mapper get one: equality-delete files keyed on a time column, OPTIMIZE compaction, and Parquet data files of a table configured as ORC/Avro. The type stays Int64, so this does not overlap #105540 (Time64(6)).

Backward incompatible: a Parquet-backed time column that showed seconds now shows microseconds, as an identity-partitioned table already did.

Validation: the new integration test (unpartitioned, identity, bucket, a file without field ids (also nested), nested struct and list, a table configured as ORC, equality deletes, compaction, Parquet row-group pruning) fails on master and passes with the fix; reverting each of the three mapper wirings separately fails exactly its part.


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

Version info

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

groeneai and others added 3 commits October 15, 2026 15:58
ClickHouse maps the Iceberg `time` type to `Int64` holding microseconds since
midnight, and every carrier of the value uses that number: manifest min/max
bounds, manifest-list partition summaries, identity partition values, the
`bucket` transform and ORC/Avro data files. Only the Parquet decoder disagreed:
it read the TIME(MICROS) column as `Time64(6)` and cast it to the requested
`Int64`, i.e. to whole seconds. So `WHERE t = <shown value>` was pruned against
bounds in another unit and returned no rows, and an identity-partitioned table
showed microseconds while an unpartitioned one showed seconds.

The Iceberg `ColumnMapper` now carries the field ids whose type is `time`, and
the Parquet `SchemaConverter` decodes such a column requested as `Int64` with
the plain INT64 decoder (its statistics and hash filters then describe the
stored value). Plain Parquet reads are unchanged. The Iceberg reads that did
not pass a mapper get one: equality-delete files keyed on a `time` column
(the key columns are read as `Int64` too), the compaction read, and Parquet
data files of a table configured with another format.

Closes ClickHouse#118807.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…oup pruning

A Parquet file without field ids resolved a `time` column by its traversal
name, which for a list element is the list's own name and for a map key is
the map's name, so those kept the seconds cast. Iceberg stores no type other
than `time` as Parquet TIME, so in a table that has `time` fields a TIME(MICROS)
column of such a file requested as `Int64` is a `time` field at any depth:
decide by `hasIcebergTimeFieldIds()` instead of a name lookup.

The integration test covers a field-id-less file with a struct field, a list
element and a map key, and a file of three row groups without column bounds,
asserting that `ParquetPrunedRowGroups` is 2 (the new decoder keeps the INT64
statistics).

The equality-delete key is retyped to the field's mapped type rather than a
hard-coded `Int64`, and compaction reads with the same mapper it writes with
(only the reader consults the last assigned field id).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Drop the processPrimitiveColumn parameter note and the compaction field-id note; keep the field-id-less fallback rationale on one line.

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

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

Pre-publication review by an independent model (engine: codex) in two rounds, plus my own review. Round 2 (798f85f6) raised no new findings.

# Sev Finding Verdict Evidence / action
1 ❌ OPTIMIZE rewrites time as bare Parquet INT64 (Compaction.cpp) DISAGREE Compaction also commits the column as long (measured, same on master), so the files match the committed schema; pre-existing, unchanged here.
2 ❌ Nested time (list element, map key) of a file without field ids stays in seconds (SchemaConverter.cpp) AGREE, fixed in 798f85f6 Iceberg stores only time as Parquet TIME, so no name lookup; tested with a struct field, list element and map key.
3 ⚠️ Parquet statistics of the new decoder are not exercised AGREE, fixed in 798f85f6 3-row-group file: ParquetPrunedRowGroups = 2, 0 with statistics disabled.
4 💡 Equality-delete key retyped to a hard-coded Int64 AGREE, fixed in 798f85f6 Uses the field's mapped type.
5 💡 Compaction builds two identical mappers AGREE, fixed in 798f85f6 One mapper.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-review-slot-8:20261015-170300

@clickhouse-gh

clickhouse-gh Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [35cfb80]

Summary: ✅


AI Review

Summary

PR #126079, reviewed at 35cfb80da6dd9d8ae5e108f7ddad0bf63c9e521e, makes Iceberg time values read from Parquet use microseconds consistently with manifest bounds and partition values. It carries the mapping through equality-delete reads, compaction, and mixed-format tables, with focused integration coverage. No actionable findings remain.

Missing context / blind spots
  • ⚠️ Relevant integration jobs are still PENDING in the underlying Praktika report. The author reports successful local regression runs; I did not independently build or execute the tests. Passing CI runs would confirm that validation.
Final Verdict

Status: ✅ Approve. No inline findings to post; CI validation remains pending.

@clickhouse-gh clickhouse-gh Bot added the pr-backward-incompatible Pull request with backwards incompatible changes label Oct 15, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. The #118807 pyiceberg table: master shows 5400 but WHERE t = 5400 returns 0 rows, every run; same on 26.8.18.2.
b Root cause explained? Only the Parquet reader cast TIME(MICROS) to Int64 seconds; bounds, partition values and bucket hold microseconds.
c Fix matches root cause? Yes. An Iceberg time field is decoded as the stored integer; no metadata path, setting or pruning rule changed.
d Test intent preserved / new tests added? New integration test test_iceberg_time_column.py (partitioning, nesting, no field ids, ORC-configured table, equality deletes, compaction, row-group pruning).
e Both directions demonstrated? Master fails both tests; the fix passes them repeatedly; each of the five mutants fails exactly its part.
f Fix is general across code paths? The three Iceberg reads that passed no mapper (equality deletes, compaction, Parquet files of ORC/Avro-configured tables) now pass one.
g Fix generalizes across inputs (params/datatypes/wrappers)? Nullable/required, struct/list/map key, with and without field ids; only TIME(MICROS) read as Int64 takes the new path.
h Backward compatible? (maintainer-approved exception only) Declared Backward Incompatible Change: Parquet-backed time shows microseconds (the documented unit) instead of seconds.
i Invariants and contracts preserved? The decoder reuses the INT64 path; the equality-delete set type equals its header type; the compaction writer is unchanged.

Session id: cron:clickhouse-impl-slot-4:20261015-163900

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @al13n321 @SmitaRKulkarni, could you review this and add can be tested (I cannot set labels right now)? The Parquet reader decoded an Iceberg time column (TIME(MICROS)) as Time64(6) and cast it to Int64 seconds while bounds and partition values hold microseconds; with the field ids from the column mapper it now decodes such a column as the stored integer.

@alexey-milovidov alexey-milovidov left a comment

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.

It looks good.

@alexey-milovidov alexey-milovidov self-assigned this Oct 16, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 16, 2026
Merged via the queue into ClickHouse:master with commit 3cadbba Oct 16, 2026
352 of 353 checks passed
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 16, 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

can be tested Allows running workflows for external contributors comp-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... pr-backward-incompatible Pull request with backwards incompatible changes pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

3 participants