Skip to content

Support timestamptz in iceberg - #130772

Merged
scanhex12 merged 12 commits into
masterfrom
iceberg-timestamptz-timezone
Nov 12, 2026
Merged

scanhex12 merged 12 commits into
masterfrom
iceberg-timestamptz-timezone

Conversation

@scanhex12

@scanhex12 scanhex12 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

iceberg_timezone_for_timestamptz is a table setting with the default UTC. It can also be set for a DataLakeCatalog database, which then applies it to its Iceberg tables. IcebergSchemaProcessor maps timestamptz and timestamptz_ns to DateTime64 in that time zone, so schema inference, pruning, schema evolution, writes and partition-literal interpretation all use the same types. The stored instants and the UTC-based partition transforms do not change.

A simplified version of #94025

Changelog category (leave one):

  • New Feature

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

Add the table setting iceberg_timezone_for_timestamptz to choose the time zone used for Iceberg timestamptz and timestamptz_ns columns.


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

Version info

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

The setting sets the time zone of the `DateTime64` type that Iceberg
`timestamptz` and `timestamptz_ns` columns are mapped to. The schema
processor keeps producing `DateTime64(p, 'UTC')`, and the time zone is
applied only to the table schema exposed to queries (`IcebergMetadata`
table schema, storage metadata, sorting key, and the schema of Iceberg
tables in a data lake catalog database). Partition transforms are UTC
based and `adjust-to-utc` depends only on the time zone being explicit,
so writes and pruning are not affected.

A simplified version of #94025

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@scanhex12 scanhex12 mentioned this pull request Nov 11, 2026
1 task done
@clickhouse-gh

clickhouse-gh Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [7602d96]

Summary: ✅


AI Review

Summary

Adds iceberg_timezone_for_timestamptz as an Iceberg table setting and a DataLakeCatalog database setting, applying the selected zone throughout schema processing while preserving stored instants and UTC partition transforms. The current code addresses the previous findings, including catalog database creation. No new actionable code findings; execution evidence for the added coverage remains unverified. No new inline comments were posted.

Tests
  • ⚠️ Obtain passing current-head results for 05620_iceberg_timezone_for_timestamptz, test_database_iceberg/test.py::test_timestamps, and test_storage_iceberg_with_spark/test_timestamptz_timezone.py::test_timestamptz_timezone. The fetched Praktika report shows the functional fixture skipped by Fast test and no test results for the targeted integration report. No local ClickHouse binary or build directory was available to run them independently. The test sources cover the material behavior, but these results are needed to confirm execution.
Final Verdict

Status: ⚠️ Request changes — provide passing results for the focused tests above. No additional source changes are requested by this review.

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label Nov 11, 2026
scanhex12 and others added 2 commits November 11, 2026 12:40
The partition and min-max pruners replaced the filter input with the
`DateTime64(p, 'UTC')` type of the manifest schema, so `KeyCondition`
converted string constants of the filter to UTC instead of the time zone
of the queried column and pruned matching files. Apply the setting to the
types used by the pruners as well, and add the reference of the test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Instead of applying `iceberg_timezone_for_timestamptz` to every type the
pruners take from the schema, the partition and min-max keys now use the
types of the filter inputs, which are the types the query sees. The
pruners no longer know about the time zone, and `setTimezoneForTimestamptz`
is only applied to the table schema.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added the comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. label Nov 11, 2026
Spark writes a `timestamptz` table partitioned by `days(ts)`, ClickHouse
reads it with `Europe/Berlin`, checks the types, values and filters, and
inserts a row with the same setting; then Spark reads all rows back and
checks that the partition of the new row is computed in UTC.

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

clickhouse-gh Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 7602d96bb with master 43871b94f (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.

Object file sizes

17 object files changed (+47.65 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Databases/DataLake/DatabaseDataLake.cpp.o 1.83 MiB 1.85 MiB +24.93 KiB (+1.33%)

711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Slowest function optimization changes (ThinLTO)

Median per-function time ratio to the master baseline: programs/clickhouse ×0.70, programs/clickhouse-keeper ×0.64 (each binary is linked separately, on a different machine and with different build flags); deltas below are relative to it.

Binary Function Master PR Δ vs median
programs/clickhouse DB::registerFunctionConversion(DB::FunctionFactory&) 5.6 s 8.9 s +5.0 s (+129%)
Compile time of recompiled translation units

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

Job report

…uery

Address the review of #130772.

Applying `iceberg_timezone_for_timestamptz` only to the table schema left
UTC types in every internal consumer that meets the expressions of the
query, so filters were evaluated in UTC in several places. Now the schema
processor takes the time zone in its accessors, keeps the per-timezone
table schemas and schema transformation DAGs in its caches, and the
consumers which are evaluated together with the query pass it: the
partition and min-max pruners, the schema transformation and the read
schema of a data file written with an older schema, and the partition
types of `DROP PARTITION`. The pruners are back to the types of the
schema processor.

The in-memory metadata of the table is shared by all queries, so it is
kept in UTC, and `adaptMetadataForQuery` makes the copy that a query sees
in `getInMemoryMetadataPtr` and in the snapshot pinned by `read`, so that
concurrent queries with different time zones do not see the types of each
other, and the setting does not reach the persisted table definition.

The test covers filters with and without pruning, data files written with
an older schema, and `DROP PARTITION` of an identity partition.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@scanhex12
scanhex12 requested a review from groeneai November 11, 2026 16:41
`getClickHouseTableSchemaById` is called with a time zone only by
`getInitialSchemaByPath`, once per data file written with an older schema,
and applying the time zone is a single pass over the columns. Drop the
unbounded `timezone_table_schemas_by_ids` cache and build the schema on
each call.

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

@groeneai groeneai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Checked on a debug build of 8ea4116: 05620 passes. Under Europe/Berlin, ALTER TABLE ... DELETE/UPDATE and lightweight DELETE hit the right row, day/hour/month partitions return the same rows with pruning on and off (including across a month boundary), and time travel to an older snapshot and an evolved schema with PREWHERE are correct. Two points inline.

The description still says the schema processor keeps producing UTC types and that pruning is not affected; the pruners and the schema transforms now take the query zone. The changelog entry could name the new setting, since timestamptz columns were already readable.

scanhex12 and others added 2 commits November 11, 2026 17:38
Address the review of #130772.

The query-level setting made the column types of a table depend on the
query, which required `adaptMetadataForQuery` to copy and adjust the
storage metadata on every `getInMemoryMetadataPtr` call, bypasses in
every path that persists metadata, and a time zone parameter in every
schema accessor and pruner.

Now `iceberg_timezone_for_timestamptz` is a `DataLakeStorageSettings`
setting (and therefore also a setting of a `DataLakeCatalog` database).
`IcebergSchemaProcessor` receives it once and maps `timestamptz` and
`timestamptz_ns` directly to `DateTime64` in this time zone, so the table
schema, the sorting key, pruning, schema evolution and `DROP PARTITION`
see the same types. An empty value is rejected, because it would produce
a `DateTime64` without an explicit time zone, which is written as
`timestamp`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…bility test

Spark now writes and reads the table in `Asia/Tokyo`, ClickHouse reads it
in `Europe/Berlin`, and the values are stored in UTC, so the test checks
that each side converts the instants by its own time zone. The literals
keep the same instants, and the first row falls on another day in Tokyo
than its `days(ts)` partition, which must be computed in UTC.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@scanhex12
scanhex12 requested a review from groeneai November 12, 2026 09:15
scanhex12 and others added 4 commits November 12, 2026 11:19
…NE = DataLakeCatalog`

`DatabaseDataLakeSettings::loadFromQuery` rejected every `iceberg_` setting on
`CREATE DATABASE`, so the time zone could not be configured for a catalog database.

Related: #130772

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The change of the `createClientConfiguration` signature was reverted in master in
44d2852, so the test compiles with `for_disk_s3` again.

PR: #130772

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@scanhex12
scanhex12 added this pull request to the merge queue Nov 12, 2026
Merged via the queue into master with commit 149b9fa Nov 12, 2026
203 checks passed
@scanhex12
scanhex12 deleted the iceberg-timestamptz-timezone branch November 12, 2026 19:18
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 12, 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

comp-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... pr-feature Pull request with new product feature pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants