Repository navigation
Iceberg 'time' type support - #105540
Iceberg 'time' type support#105540ianton-ru wants to merge 77 commits into
Conversation
|
Workflow [PR], commit [7a0989d] Summary: ❌
|
This reverts commit a262f80.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 98/222 (44.14%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 6 line(s) · Uncovered code |
AI assisted (Cursor)
….cpp` Fixes `readability-static-definition-in-anonymous-namespace` in the `arm_tidy` build: https://s3.amazonaws.com/clickhouse-test-reports/PRs/105540/af574c6692d3476366c069eba5cbddedc6f45029/pr/build_arm_tidy_1_4/build_clickhouse/build_clickhouse.log PR: ClickHouse#105540 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
…upport Master replaced the `apache/orc` library with a native ORC reader and writer (`ORC::` instead of `orc::`) and moved the writing of the values from `ORCBlockOutputFormat` into `ORC/Writer.cpp`. The time-of-day support of this PR is ported accordingly: `IntegerColumnWriter` writes `Time` and `Time64` as an ORC `LONG` of microseconds since midnight and checks the range, and the reader uses the `ORC::` API for the `iceberg.long-type` attribute. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…cpp` Fixes `readability-duplicate-include` in clang-tidy: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=105540&sha=e6eee4176d7cd754f32baebd371b3a5afa832e24&name_0=PR&name_1=Build%20%28arm_tidy%2C%201%2F4%29 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Avro writer writes a `Map` as an Avro `map`, whose keys are strings, while the Iceberg Avro mapping requires a map with non-string keys to be an array of key-value records, with a `time` key as a `long` annotated `time-micros`. A data file written that way would not match the Iceberg schema for other readers. Reject writing a `Map` with `Time` or `Time64` keys into an Iceberg Avro data file (inserts, mutations and compaction) instead of committing such a file. Parquet and ORC data files keep the type of the keys. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…xception messages The error of the Parquet writer can be rethrown with the original message inside, so the error code appears twice in the text. Print it once. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…es.cpp` `getDecimalScale` was only available transitively, which broke the `amd_msan` build: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=105540&sha=e74cbdcdb497aec3d408556ae92b705a1a031324&name_0=PR&name_1=Build%20%28amd_msan%29 PR: ClickHouse#105540 Co-Authored-By: Claude Opus 5.5 <[email protected]>
… `avro` Python package The package is not installed in the CI image, so the test failed with `ModuleNotFoundError`. The object container file with the `time-millis` and `time-micros` columns is now written by hand. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The test ran more than 200 client processes and exceeded 180 seconds in the flaky check with sanitizers. The queries of each table are now batched into a few client calls, and `log_comment` is used instead of `query_id` to find the pruning queries in `system.query_log`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ime64(6)` The corpus test was added on master and pinned the old `Int64` type of the `tm` columns. This PR intentionally reads Iceberg `time` as `Time64(6)`; the content checks still pass. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged
|
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes31 object files changed (+234.51 KiB total), 0 added.
719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units72 translation units recompiled, 695 s compile time in total, 72 of them have a recent master baseline. |
# Conflicts: # src/Databases/DataLake/RestCatalog.cpp # src/Processors/Formats/Impl/AvroRowInputFormat.cpp # src/Storages/ObjectStorage/DataLakes/Iceberg/SchemaProcessor.cpp
…aster Master removed Arrow from the native Parquet writer, so `parquet::Int64Type` no longer exists there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…g Avro data files The Avro writer serializes the whole map key as a string, so `Map(Tuple(tm Time64(6)), Int64)` hit the same problem as a direct `Time64` key. Check the key type recursively in `checkIcebergTimeColumnIsWritable` and add the case to `05493_iceberg_avro_time_map_key`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts: master added a `timezone_for_timestamptz` parameter to `IcebergSchemaProcessor` and `getSimpleType`, while this PR added `time_as_int64`; both are kept, with `time_as_int64` before `timezone_for_timestamptz`.
…ror code and duplicate include https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=105540&sha=871a42d637483e168733df2b5321313eecea22ca&name_0=PR&name_1=Style%20check ClickHouse#105540 Co-Authored-By: Claude Opus 5.5 <[email protected]>
| { | ||
| /// The microseconds of an Iceberg `time` are the ticks of `Time64(6)`, while the cast of an | ||
| /// integer to `Time64` would take them as seconds. An integer type is still read as is. | ||
| if (isIcebergTimeLong(*orc_type) && !(type_hint && WhichDataType(type_hint).isNativeInteger())) |
There was a problem hiding this comment.
[Blocker] Preserve stored microseconds for every integer target
isNativeInteger excludes Int128/UInt128/Int256/UInt256, and inspecting the outer hint also misses LowCardinality(Int64). These explicit integer schemas therefore enter the new Time64(6) branch. The final castColumnToRequestedType converts that time to an integer in seconds, silently changing the stored value; the ordinary Int64 target still returns microseconds.
For example, write SELECT toTime64('12:34:56.123456', 6) AS t FORMAT ORC, then read the file with file('time.orc', ORC, 't Int128'): this path produces 45296, whereas reading the same file as t Int64 produces 45296123456. This follows from the current decoder and decimal-to-integer conversion; I could not execute it locally because this checkout has no ClickHouse binary/build. The same scalar reader is used inside containers and union branches, where orcIntegerBranchWidensTo explicitly accepts wide integer hints.
Please classify the unwrapped target once at this decoding boundary and preserve the raw Int64 representation for all integer targets before the final widening/dictionary cast. Add a focused stateless regression comparing Int64, Int128, and LowCardinality(Int64) reads of a tagged time column with a nonzero fractional part.
There was a problem hiding this comment.
🕵 Fixed in 7a0989d: the ORC scalar reader now classifies the target after removing Nullable and LowCardinality and keeps the raw Int64 for every integer type (isInteger instead of isNativeInteger), so Int128, UInt128, Int256 and UInt256 return the stored microseconds like Int64 does. Added 05872_orc_time_of_day_integer_targets, which reads a tagged time column with a fractional part as Int64, UInt64, the wide integers, Nullable(Int128), LowCardinality(Int64), LowCardinality(Nullable(Int64)), and inside Tuple and Array; all return 45296123456.
# Conflicts: # src/Databases/DataLake/GlueCatalog.cpp # src/Processors/Formats/Impl/AvroRowInputFormat.cpp # src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergWrites.cpp # src/Storages/ObjectStorage/DataLakes/Iceberg/Utils.cpp # src/Storages/ObjectStorage/DataLakes/Iceberg/Utils.h
…tType` The test was added on master and calls `DataLake::getType` with two arguments, while this branch added the `time_as_int64` parameter. This broke the `Build (arm_tidy, 4/4)` job: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=105540&sha=74711314b5d1a472c2e5e4e38c6f0ed5c2cbe573&name_0=PR&name_1=Build%20%28arm_tidy%2C%204%2F4%29 ClickHouse#105540 Co-Authored-By: Claude Fable 5.2 <[email protected]>
…r every integer target The ORC reader decoded a `long` with the attribute `iceberg.long-type` = `TIME` as `Time64(6)` unless the requested type was a native integer. `isNativeInteger` excludes `Int128`, `UInt128`, `Int256` and `UInt256`, so for these the final cast converted the time to seconds (`45296`), while `Int64` returned the stored microseconds (`45296123456`). Now every integer type, also inside `Nullable` or `LowCardinality`, is read as is. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Map the Iceberg
timetype toTime64(6)instead ofInt64. The Iceberg spec definestimeas a time of day of microsecond precision without a date or time zone, which is exactlyTime64(6), andTime64stores the same microseconds, so manifest bounds, partition values,buckethashes and data files keep their values.What changes:
timetoTime64(6)(in the table metadata and in the schemas from the REST, Glue and Hive catalogs). ParquetTIME(MICROS)is decoded natively, ORClongcolumns with the Iceberg attributeiceberg.long-type=TIMEare read as the stored microseconds (before, the cast took them as seconds), Avrotime-millis/time-microsare rescaled to the requestedTime/Time64scale. Partition values stored astime-microsor as a plainlongare brought to the type of the column.TimeandTime64up to scale 6 are written as Icebergtimeinto Parquet (TIME(MICROS)), ORC (longwithiceberg.long-type=TIME) and Avro (longwithtime-micros) data files, into the manifest partition values and the column bounds. Values outside of [00:00:00, 24:00:00) are rejected. Before, aTimecolumn was declared as Icebergtimebut written as a plain integer of seconds.TimeorTime64(scale up to 6) columns is allowed again: the refusal added as a stopgap in 51eb6ae (and its test05361_iceberg_create_time_column_rejected) is replaced by the proper support.Time64with a larger scale is still refused.icebergHash/icebergBucketsupportTimeandTime64, hashing the microseconds as the spec requires.TimeandTime64, and schema inference reads ParquetTIME, Avrotime-millis/time-microsand the ORC time-of-daylongasTime64.iceberg_time_as_int64(enabled bycompatibilityup to 26.10) readstimeasInt64microseconds, as after Read Icebergtimecolumns of Parquet data files as microseconds #126079. Writing atimefield from anInt64column under this setting is refused instead of producing a file that spec-compliant readers reject.Interoperability is checked with Trino reading Parquet, ORC and Avro data files written by ClickHouse (Spark has no
timetype), and with pyiceberg-written tables intest_iceberg_time_column.py.Closes: #118806
Related: #126079
Related: #88063
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Iceberg
timecolumns are read asTime64(6)instead ofInt64microseconds since midnight, and ClickHouseTimeandTime64columns are written as Icebergtimein Parquet, ORC and Avro data files. To readtimeasInt64as before, enable settingiceberg_time_as_int64. The Parquet, ORC and Avro formats support writingTimeandTime64as a time of day, and Avrotime-millis/time-microsare read asTime64.Documentation entry for user-facing changes
Before:
Now:
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/105540]