Repository navigation
Conversation
Support `timestamp_ns` and `timestamptz_ns` Iceberg types by mapping them to `DateTime64(9)` in ClickHouse, gated behind the `iceberg_allow_nanosecond_timestamps` setting. Closes ClickHouse#97015
|
Workflow [PR], commit [e7759b3] Summary: ✅ AI ReviewSummaryThis PR adds read-side support for Iceberg v3 nanosecond timestamp types by mapping Missing context
ClickHouse Rules
Final Verdict
|
Support `timestamp_ns` and `timestamptz_ns` Iceberg types by mapping them to `DateTime64(9)` in ClickHouse, gated behind the `iceberg_allow_nanosecond_timestamps` setting. Closes ClickHouse#97015
c8a76d0 to
64c5689
Compare
…implementation based on Iceberg changes merged from main
2d898a3 to
76bbac2
Compare
|
|
||
| String column_type = column.GetType(); | ||
| if (column_type == "timestamp") | ||
| if (column_type == "timestamp" || column_type == "timestamp_nano") |
There was a problem hiding this comment.
Wrong string literal "timestamp_nano" instead of "timestamp_ns"
Medium Severity
The condition checks for "timestamp_nano" but everywhere else in the codebase — Constant.h, SchemaProcessor.cpp, the Iceberg spec, and the test metadata JSON — the type is "timestamp_ns". The string "timestamp_nano" appears nowhere else in the entire repository. If AWS Glue returns "timestamp_ns" for nanosecond timestamp columns, the condition won't match, so getActualTimestampType won't be called. This means for a timestamptz_ns column that Glue reports without timezone info (as it does for regular timestamptz → "timestamp"), the metadata lookup that recovers the timezone would be skipped, resulting in a DateTime64(9) instead of the correct DateTime64(9, 'UTC').
There was a problem hiding this comment.
actually "timestamp_nano" is correct, as in - this is what AWS Glue actually returns. This is the Glue catalog column type, not the Iceberg spec type.
As to why it does that - it looks like a bit of a mess TBH, but this is the current behaviour:
The Iceberg Java library's https://github.com/apache/iceberg/blob/main/aws/src/main/java/org/apache/iceberg/aws/glue/IcebergToGlueConverter.java has an explicit case TIMESTAMP: return "timestamp" but no case for TIMESTAMP_NANO. The default branch does
type.typeId().name().toLowerCase(Locale.ENGLISH), and the enum value is https://github.com/apache/iceberg/blob/main/api/src/main/java/org/apache/iceberg/types/Type.java, producing "timestamp_nano".
"timestamp_ns" is the type string in Iceberg metadata JSON — a different namespace.
…ssing documentation on current mappings from Iceberg types to ClickHouse types, during schema inference, including new nanosecond types
…log fallback to preserve nanosecond precision for `timestamp_nano` columns when metadata lookup fails
…nd-support' into issue-97015-add-iceberg-nanosecond-support
|
@alesapin cursor's review comments addressed, test coverage fixed, the only test failure seems unrelated to the changes - so it looks ready to go from my side. Please have a look when you have time and let me know if there's anything else required to get it over the line. Thanks! |
|
@alesapin @Algunenano all tests pass, please have a look when you have time |
LLVM Coverage Report
PR changed lines: PR changed-lines coverage: 84.97% (147/173, 0 noise lines excluded) |
|
@alesapin , @Algunenano please could you have a look? or provide an approximate ETA for when you will have time for this? Also, anything else I need to do to get this over the line?.. or if there are any concerns about applicability as a whole, or internal implementation is cooking - just let me know |
Either @alesapin or somebody with experience in the datalake code will review it once they have time |


Support
timestamp_nsandtimestamptz_nsIceberg types by mapping them toDateTime64(9)in ClickHouse. Closes #97015Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Support reading Iceberg v3 nanosecond timestamp types (
timestamp_nsandtimestamptz_ns), mapped toDateTime64(9)andDateTime64(9, 'UTC'). Note: this does not constitute full Iceberg v3 feature set support, nor does it include support for writing Iceberg v3 with these new types - this just enables Clickhouse to read Iceberg data with these types in the schema.Documentation entry for user-facing changes
Motivation:
While full Iceberg v3 support is being worked on, this is a self-contained small change which solves a real usability problem today: users working with high-frequency data (trading, telemetry, scientific measurements) need nanosecond precision but are forced to store timestamps as plain Int64 (epoch nanos) in their Iceberg tables to remain compatible with ClickHouse. This loses all type semantics — no automatic timezone handling, no date arithmetic, no proper formatting by default.
Type mappings:
timestamp_ns→DateTime64(9)(nanoseconds, no timezone)timestamptz_ns→DateTime64(9, 'UTC')(nanoseconds, UTC)Example:
Note
Medium Risk
Changes Iceberg schema inference and Glue catalog type resolution for timestamp columns, which can affect inferred column types for existing tables. Scope is limited to read-side type mapping and adds tests to reduce regression risk.
Overview
Adds read-side support for Iceberg v3 nanosecond timestamp types by mapping
timestamp_ns/timestamptz_nstoDateTime64(9)(UTC fortimestamptz_ns) during schema inference.Improves AWS Glue catalog handling of timestamp columns by resolving the exact Iceberg timestamp variant from the table metadata (including Glue’s
timestamp_nanofallback), and reuses Iceberg metadata JSON loading utilities (including compressed metadata detection).Updates user docs with an explicit Iceberg→ClickHouse type mapping table, and adds unit + stateless query tests covering the new timestamp mappings and Glue resolution behavior.
Written by Cursor Bugbot for commit 682530b. This will update automatically on new commits. Configure here.