Repository navigation
Conversation
Iceberg tables written with DateTime/DateTime64 declared `timestamp` in metadata while Parquet files used isAdjustedToUTC=true, breaking spec-following readers such as pyiceberg. Map these columns to `timestamptz` (or `timestamptz_ns` for DateTime64(9)) instead. Closes: ClickHouse#114854
|
Workflow [PR], commit [6d6c768] Summary: ✅
AI ReviewSummaryReviewed PR head Consumer tracing covered insert conversion to the read-back schema; insert, mutation, and compaction writers receiving the schema-derived mapper; recursive Parquet timestamp annotations; ORC instant encoding, schema inference, and decoding; and manifest partition serialization using the explicit timezone. The Avro data-file serializer remains the divergent consumer described below. Missing context / blind spots
Findings
Tests
Final VerdictStatus: |
|
@ylw510 can you fix the tidy build? |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units52 translation units recompiled, 526 s compile time in total, 52 of them have a recent master baseline. |
# Conflicts: # src/Storages/ObjectStorage/DataLakes/Iceberg/Utils.cpp
The writer creates format version 2 tables by default, and timestamptz_ns is a format version 3 type, which spec-following readers reject in older tables. The insert path converts the block to the live Iceberg schema type, so DateTime64(9) is written with microsecond precision, exactly as before the change. This also restores the expected output of 04652_iceberg_mv_target_stale_schema_write, which failed with the nanosecond mapping. Related: ClickHouse#114854
A ClickHouse-written DateTime column is now declared as timestamptz and read back as DateTime64(6, 'UTC'). The new test 04894_iceberg_timestamp_metadata_parquet_consistency printed the values in the server time zone, so it failed whenever that was not UTC; its columns now carry an explicit UTC zone. test_v3_primitive_types expects Trino to render the zone. 05212_iceberg_manifest_compaction_conflicting_manifest_schema builds its schema conflict by flipping timestamptz to timestamp instead of the other way around. 05213_iceberg_partition_pruning_timezone names the instants of its non-UTC arms with zoned constants, because a string literal is now parsed in the column's UTC zone. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=114859&sha=a2683bac44c7393ade577a6f3d66f17937904fef&name_0=PR PR: ClickHouse#114859
Tables written before DateTime and DateTime64 were declared as timestamptz have timestamp columns. generateModifyColumnMetadata regenerated the type as timestamptz, and checkValidSchemaEvolution rejected timestamp to timestamptz, so even a no-op MODIFY COLUMN or a change to Nullable failed on such tables. The existing timestamp type is now kept and only the nullability changes. The new test builds such a table by rewriting the metadata file before any data is written.
…ng_timezone Issue ClickHouse#119173 is about a string literal against an Iceberg timestamp column under a non-UTC session, and ClickHouse no longer writes such columns. The original string-literal arms now run against a table whose column really is a timestamp, produced by rewriting the metadata file before any data is written, in separate clickhouse-local processes so that no metadata cache can hide the rewrite. The zoned-constant arms on the timestamptz table stay, since they cover pruning of the type ClickHouse now writes.
The documentation of the Iceberg engine still said that every DateTime and DateTime64 column is written as timestamp and that ClickHouse cannot generate timestamptz. Also fix a comment in 05315_iceberg_drop_partition_date_transform_aliases that described the old read-back type.
The Iceberg spec maps timestamptz to the ORC timestamp with local time zone kind and timestamp to the ORC timestamp kind, and Java Iceberg rejects a data file whose ORC kind differs from the schema. Since DateTime and DateTime64 are declared as timestamptz, the ORC writer, which always wrote TIMESTAMP, produced such a mismatch. The Iceberg column mapper now lists the timestamp and timestamp_ns paths as local timestamp paths, the mechanism Delta already uses for timestamp_ntz. The ORC writer uses TIMESTAMP_INSTANT for a lake column that is not a local timestamp and keeps TIMESTAMP otherwise, so plain ORC output is unchanged and a timestamp column of an older table, including one kept by MODIFY COLUMN, still gets TIMESTAMP. The ORC writer already encodes TIMESTAMP_INSTANT as UTC seconds. The Parquet writer consults the same paths, so a timestamp column of an older table is now written with isAdjustedToUTC=false, as the spec requires, instead of true. Review comment: ClickHouse#114859 (comment)
| return {"timestamp", true}; | ||
| /// The Parquet writer sets `isAdjustedToUTC=true`, so declare `timestamptz` instead of `timestamp`. | ||
| /// `timestamptz_ns` is a format version 3 type, so `DateTime64(9)` keeps the microsecond type, as before. | ||
| return {Iceberg::f_timestamptz, true}; |
There was a problem hiding this comment.
[P2] Emit the Avro UTC annotation for the new timestamp mapping
This shared mapping also applies to IcebergLocal(..., 'Avro'). Creating an Avro table with ts DateTime64(6) and inserting a row now declares timestamptz in table metadata, but AvroSerializer::createSchemaWithSerializeFn (AvroRowOutputFormat.cpp:209–225) still writes only long plus logicalType: timestamp-micros; it never emits adjust-to-utc. The Iceberg Avro mapping defines the absent annotation as false, so the data file describes a zone-less timestamp. Iceberg Java's schema conversion consequently reconstructs TimestampType.withoutZone, contradicting the table's new type. The Parquet and ORC fixes therefore introduce the same schema/data mismatch for Avro output.
Please have the Avro data writer emit adjust-to-utc: true for timestamptz paths using the column mapper, retain false for legacy timestamp paths, and add a focused data-file schema assertion. Updating Iceberg::getAvroType alone would only affect manifest partition schemas, not these data files.
|
🕵️ @ylw510
|
# Conflicts: # src/Storages/ObjectStorage/DataLakes/Iceberg/SchemaProcessor.cpp
The functional tests already check the `timestamptz` mapping. Avro data files still lack the `adjust-to-utc` annotation, which needs a change in the Avro library, so the documentation says so until a follow-up adds it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tamp-metadata Co-authored-by: Young <[email protected]>
Co-authored-by: Young <[email protected]>
Co-authored-by: Young <[email protected]>
|
fixes #125202 |
Closes: #114854
When ClickHouse creates or evolves an Iceberg schema, it declared every
DateTimeandDateTime64column astimestamp, while the Parquet writer marks the data asisAdjustedToUTC=true. Spec-following readers such as pyiceberg then refuse to scan the table. New columns are now declared astimestamptz:TIMESTAMP_INSTANTfortimestamptzand keepsTIMESTAMPfortimestampcolumns.timestampcolumn of an existing table keeps its type onALTER TABLE ... MODIFY COLUMN, because Iceberg does not allowtimestampto becometimestamptz.Writes are converted to the table's read-back type,
DateTime64(6, 'UTC'), before they reach the format writer. SoDateTime64(7..9)columns andoutput_format_parquet_datetime_as_uint32cannot produce a data file that disagrees withtimestamptz.Avro data files are not changed yet. The Avro writer still emits
timestamp-microswithout theadjust-to-utcannotation, which needs a change in the Avro library; it is left for a follow-up and documented.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Iceberg tables created or evolved by ClickHouse now declare
DateTimeandDateTime64columns astimestamptzinstead oftimestamp, matching the UTC-adjusted timestamps in the Parquet and ORC data files. Before, spec-following readers such as pyiceberg could not scan these tables. Such columns are now read back asDateTime64(6, 'UTC')instead ofDateTime64(6). Values are displayed in UTC, and string literals compared with or inserted into them are parsed in UTC instead of the session time zone. To keep the previous interpretation, give the time zone explicitly, for exampletoDateTime64('2026-01-01 00:00:00', 6, 'Europe/Amsterdam'), or convert on read withtoTimeZone. Existingtimestampcolumns keep their type and behavior.Workflow [PR]
Sync PR [sync-upstream/pr/114859]