Repository navigation
Conversation
Contributor
|
Workflow [PR], commit [a25195b] Summary: ❌
|
Avogar
reviewed
Sep 30, 2025
Avogar
approved these changes
Oct 30, 2025
al13n321
enabled auto-merge
November 3, 2025 18:55
Contributor
|
@al13n321 is that expected? 25.8.13: SELECT
timestamp_x2Ecolumn,
timestamptz_x2Ecol
FROM s3('http://minio:9000/warehouse/data/data/**.parquet', 'admin', 'password')
ORDER BY tuple(*) ASC
LIMIT 1
SETTINGS input_format_parquet_use_native_reader_v3 = 0SELECT
timestamp_x2Ecolumn,
timestamptz_x2Ecol
FROM s3('http://minio:9000/warehouse/data/data/**.parquet', 'admin', 'password')
ORDER BY tuple(*) ASC
LIMIT 1
SETTINGS input_format_parquet_use_native_reader_v3 = 1 |
8 of 27 tasks
alexey-milovidov
pushed a commit
to niyue/ClickHouse
that referenced
this pull request
Oct 12, 2026
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Parquet no-timezone timestamps (isAdjustedToUTC=false) are now read as DateTime64(..., 'UTC') instead of DateTime64(...). This is less incorrect as converting such UTC timestamp to string produces a representation of the correct local time. Use input_format_parquet_local_time_as_utc=0 to get the old behavior. Resolves #87469.
Details
Closes #87469
What clickhouse type should we use for parquet timestamps with isAdjustedToUTC=false? DateTime64(3) or DateTime64(3, 'UTC')? Copying explanation from #87469 (comment) :
AFAIU, neither behavior is actually correct, and the new behavior seems less incorrect.
https://github.com/apache/parquet-format/blob/master/LogicalTypes.md#local-semantics-timestamps-not-normalized-to-utc says:
ClickHouse doesn't have a data type like that. Both DateTime64(3) and DateTime64(3, 'UTC') are the number of milliseconds since Unix epoch, representing a specific point in time. The timezone parameter only affects parsing and formatting.
DateTime64(3, 'UTC') seems more correct: if converted to string, it'll show the correct "year, month, day, hour, minute, second and subsecond" that the parquet file had in mind. Like in this paragraph in parquet documentation:
So, this PR changes it from DateTime64(3) to DateTime64(3, 'UTC'), behind a compatibility setting. Or maybe we should use String instead?
Also rewrote most of type mapping information in docs/en/interfaces/formats/Parquet/Parquet.md.