Repository navigation
Conversation
Every `DateTime` and `DateTime64` column was declared as Iceberg `timestamp`, which the specification defines as a date and time of day without a timezone, even when the ClickHouse type carried an explicit one. At the same time the data file said the opposite: the Parquet writer always set `isAdjustedToUTC = true`, which is the annotation the specification reserves for `timestamptz`. A ClickHouse timestamp is always an instant and the timezone parameter only selects how it is rendered, so an explicitly specified timezone is exactly the "point in time" semantics of `timestamptz`, and its absence is the zone-less `timestamp`. The schema now says that, and the data file agrees: Parquet emits `isAdjustedToUTC = false` for `timestamp`, and ORC distinguishes `timestamp` from `timestamp_instant`. Both writers learn which paths are zone-less from the Iceberg schema through the column mapper, so a write without one keeps declaring its timestamps UTC-adjusted and nothing changes outside Iceberg. Avro data files cannot carry the annotation, because it is an Iceberg convention on top of the Avro logical type and avro-cpp has no way to attach it; that is documented as a limitation. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
|
Workflow [PR], commit [ecc1e95] Summary: ❌
AI ReviewSummaryThis PR updates the Iceberg write path so Findings❌ Blockers
💡 Nits
Tests
Final Verdict
LLVM Coverage ReportMeasured on commit ecc1e95.
Changed lines: Changed C/C++ lines covered: 80/82 (97.56%) · Uncovered code |
| case TypeIndex::DateTime: | ||
| return { | ||
| assert_cast<const DataTypeDateTime &>(*type).hasExplicitTimeZone() ? Iceberg::f_timestamptz : Iceberg::f_timestamp, true}; | ||
| case TypeIndex::DateTime64: | ||
| return {"timestamp", true}; | ||
| return { | ||
| assert_cast<const DataTypeDateTime64 &>(*type).hasExplicitTimeZone() ? Iceberg::f_timestamptz : Iceberg::f_timestamp, |
There was a problem hiding this comment.
This makes every explicit timezone look like an Iceberg timestamptz, but our read path can only recover that as DateTime64(..., 'UTC') (IcebergSchemaProcessor::getSimpleType in SchemaProcessor.cpp). For example, DateTime64(6, 'Europe/Berlin') will write successfully here, then come back after ATTACH/restart/on another node as DateTime64(6, 'UTC'), so the same stored instants start rendering different strings. The new test only covers 'UTC', which hides the problem.
Unless we also persist the original ClickHouse timezone somewhere outside the Iceberg type, this needs to reject non-UTC explicit timezones on the Iceberg write path instead of silently claiming full timestamptz support.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
|
||
| - ClickHouse cannot create an Iceberg schema containing `Bool`, `Decimal`, `FixedString`, `Int8`, `UInt8`, `Int16`, or `UInt16`, or add or modify a column to one of these types. The operation fails with an unsupported-type exception. This does not prevent inserting `Bool` or `Decimal` values into existing Iceberg columns. | ||
| - When ClickHouse creates or evolves an Iceberg schema, it maps every `DateTime` and `DateTime64` column to Iceberg `timestamp`, which has microsecond precision and no timezone. ClickHouse cannot generate `timestamptz`, `timestamp_ns`, or `timestamptz_ns` schema types, so higher precision and timezone semantics are not represented in the Iceberg schema. | ||
| - When ClickHouse creates or evolves an Iceberg schema, it maps a `DateTime` or `DateTime64` column with an explicitly specified timezone to Iceberg `timestamptz`, and one without to the zone-less `timestamp`. Both have microsecond precision: ClickHouse cannot generate the `timestamp_ns` or `timestamptz_ns` schema types, so nanosecond precision is not represented in the Iceberg schema. |
There was a problem hiding this comment.
This page is generated from the engine's structured docs, so editing the .mdx output inside the {/*AUTOGENERATED_START*/} block will keep failing the docs check and will be overwritten on the next generation pass. Please move this wording change to the source of truth in src/Storages/ObjectStorage/registerStorageObjectStorage.cpp (around the existing Iceberg "Schema and write compatibility limitations" section), or route it through the dedicated autogenerated-docs workflow.
An INSERT into a Delta table whose schema declares a timestamp_ntz column committed a data file that annotated the column Timestamp(isAdjustedToUTC=true, MICROS). Delta defines timestamp_ntz as an unadjusted wall clock timestamp, so Spark refused every later read of the table with java.lang.RuntimeException: Unable to create Parquet converter for data type "timestamp_ntz" whose Parquet type is int64 time(TIMESTAMP(MICROS,true)) Two independent facts produced this. The kernel schema visitor wired visit_timestamp and visit_timestamp_ntz to the same visitor, so both Delta types became DateTime64(6) and the distinction was gone before the writer saw it; ClickHouse has no wall clock type that could carry it either. The Parquet writer then hardcoded isAdjustedToUTC=true at both timestamp branches, which is right for the general Parquet format because a DateTime64 is an instant, but wrong for a column the Delta log declares timestamp_ntz. Rather than consult the DateTime64 timezone parameter, which would change every general-format write and contradict the rule settled in ClickHouse#87872, the distinction is kept where it is produced and delivered where it is needed. The visitor records is_timestamp_ntz on its field, the traversal collects the dotted paths of those leaves, TableSnapshot caches them with the rest of the schema, and the Delta write path hands them to the writer through ColumnMapper, which already carries per-path lake facts that a ClickHouse type cannot express (iceberg_string_paths, iceberg_optional_paths). Nested paths are spelled the way the Parquet writer spells a column path (a struct field's own name, element for an array child, key and value for a map's) rather than reusing the kernel's child names, which are not guaranteed to be those words. Only the annotation changes; the stored int64 is identical, so the ClickHouse round trip stays lossless. This is the inverse of the documented read-side rule that reads an unadjusted timestamp as DateTime64(N, 'UTC'). The mapper is attached only when the table actually has a timestamp_ntz column and only for Parquet, so a Delta table without one keeps its exact current behaviour, and ORC and Avro never see a mapper they would read as Iceberg metadata. ParquetBlockOutputFormat now passes std::nullopt when the mapper's field-id map is empty: an engaged but empty optional makes convertSchema report the first column as having no Iceberg field id, so a mapper carrying only timestamp paths would otherwise break every Delta INSERT. An Iceberg mapper always has an id per field, so Iceberg is unaffected. The shared annotation seam is shaped identically to the in-flight ClickHouse#118601, which adds it for Iceberg but does nothing for Delta, so either merge order is a mechanical rebase. Tests: two integration tests in test_storage_delta covering the flat case (with Nullable, a Delta timestamp control and a char/varchar column) and the nested case (struct field, array element, map value, plus a Delta timestamp sibling inside the same struct), both asserting the _delta_log types first so they cannot pass vacuously, the written annotation, a Spark read and the ClickHouse round trip. 02735_parquet_encoder gains a logical_type assertion because desc file() reports DateTime64(N, 'UTC') for both flag values, so nothing on master would have caught a global flip of the default. Closes ClickHouse#120653.
|
fixes #125202 |
Every
DateTimeandDateTime64column was declared as Icebergtimestamp, which the specification defines as a date and time of day without a timezone, even when the ClickHouse type carried an explicit one. At the same time the data file said the opposite: the Parquet writer always setisAdjustedToUTC = true, which is the annotation the specification reserves fortimestamptz.A ClickHouse timestamp is always an instant and the timezone parameter only selects how it is rendered, so an explicitly specified timezone is exactly the "point in time" semantics of
timestamptz, and its absence is the zone-lesstimestamp. The schema now says that, and the data file agrees: Parquet emitsisAdjustedToUTC = falsefortimestamp, and ORC distinguishestimestampfromtimestamp_instant.Both writers learn which paths are zone-less from the Iceberg schema through the column mapper, so a write without one keeps declaring its timestamps UTC-adjusted and nothing changes outside Iceberg. Avro data files cannot carry the annotation, because it is an Iceberg convention on top of the Avro logical type and avro-cpp has no way to attach it; that is documented as a limitation.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Support timestamptz in iceberg tables
Workflow [PR]
Sync PR [sync-upstream/pr/118601]