Repository navigation
Support timestamptz in iceberg - #130772
Conversation
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]>
|
Workflow [PR], commit [7602d96] Summary: ✅
AI ReviewSummaryAdds Tests
Final VerdictStatus: |
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]>
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]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes17 object files changed (+47.65 KiB total), 0 added.
711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Slowest function optimization changes (ThinLTO)Median per-function time ratio to the master baseline:
Compile time of recompiled translation units133 translation units recompiled, 1263 s compile time in total, 133 of them have a recent master baseline. |
…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]>
`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
left a comment
There was a problem hiding this comment.
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.
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]>
…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]>
`createClientConfiguration` takes `HTTPConnectionGroupType` instead of `for_disk_s3` now. Same change as in #131033 CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=130772&sha=736b9ada751e7ffd6267e3a7963b71581b36edf0&name_0=PR&name_1=Build%20%28arm_tidy%2C%204%2F4%29 PR: #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]>
iceberg_timezone_for_timestamptzis a table setting with the defaultUTC. It can also be set for aDataLakeCatalogdatabase, which then applies it to its Iceberg tables.IcebergSchemaProcessormapstimestamptzandtimestamptz_nstoDateTime64in 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):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Add the table setting
iceberg_timezone_for_timestamptzto choose the time zone used for Icebergtimestamptzandtimestamptz_nscolumns.Workflow [PR]
Sync PR [sync-upstream/pr/130772]
Version info
26.11.1.2123-master(included in26.11and later)