Skip to content

Fix ORC TIMESTAMP values before the first time zone transition - #130354

Merged
Algunenano merged 3 commits into
ClickHouse:masterfrom
Algunenano:orc-timestamp-ancient-offset
Nov 10, 2026
Merged

Algunenano merged 3 commits into
ClickHouse:masterfrom
Algunenano:orc-timestamp-ancient-offset

Conversation

@Algunenano

@Algunenano Algunenano commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

The native ORC reader converted between the writer and reader time zones with DateLUTImpl::timezoneOffset, which returns the local mean time before the first transition of a zone (Asia/Shanghai +08:05:43 before 1901). liborc uses the oldest standard time there (+08:00), so values before the first transition were shifted by the difference, e.g. 1850-01-01 00:00:00 UTC read with input_format_orc_reader_time_zone_name = 'Asia/Shanghai' gave 1849-12-31 15:54:17 instead of 16:00:00. Now the reader uses the oldest standard offset before the first transition, as the reference implementation does.

Related: #127690

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

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

Version info

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

The native ORC reader converted between the writer and reader time zones with
`DateLUTImpl::timezoneOffset`, which returns the local mean time before the
first transition of a zone (Asia/Shanghai +08:05:43 before 1901). `liborc` uses
the oldest standard time there (+08:00), so the new reader shifted such values
by the difference. Use the oldest standard offset before the first transition,
as the reference implementation does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Algunenano Algunenano added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Nov 9, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [06f4f08]

Summary: ✅


AI Review

Summary

The PR makes ancient ORC timestamp decoding and writer statistics use the oldest standard offset, matching liborc. Reviewed head 06f4f0870383295a1acbf4a7e334ee1c06a0f3ea, the complete diff, surrounding reader/writer and pruning code, and all prior discussion. Both previous findings are addressed for newly written files; the author's compatibility tradeoff for files from the unreleased native writer is reasonable. No new blockers or majors found.

Missing context / blind spots
  • ⚠️ The added regression was inspected but not executed locally: this checkout has no ClickHouse binary or configured build. The current CI report did not provide a completed result for 05616_orc_timestamp_before_first_transition; its successful execution in normal CI would close this gap.
Final Verdict

Status: ✅ Approve. No code changes requested; normal CI validation remains necessary.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Nov 9, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-formats Input/output formats (CSV/JSON/Parquet/ORC/Arrow/Protobuf/etc.). label Nov 9, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 06f4f0870 with master a380d00da (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

4 object files changed (+34.27 KiB total), 1 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Processors/Formats/Impl/ORC/Timezone.cpp.o new 32.70 KiB +32.70 KiB

719 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-keeper ×1.08 (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&) 7.4 s 18.7 s +11.3 s (+153%)
Compile time of recompiled translation units

9 translation units recompiled, 13 s compile time in total, 8 of them have a recent master baseline.

Job report

… writer

`cctz::time_zone::next_transition` skips no-op records, so `Europe/Lisbon` got the wrong offset before 1912. Read the embedded tzdata like `liborc`, and use the same offsets for the writer's timestamp statistics so filter pushdown does not drop rows. This also removes the `cctz` include that broke the FreeBSD build.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Algunenano
Algunenano added this pull request to the merge queue Nov 10, 2026
Merged via the queue into ClickHouse:master with commit 1847ab8 Nov 10, 2026
370 of 371 checks passed
@Algunenano
Algunenano deleted the orc-timestamp-ancient-offset branch November 10, 2026 17:13
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Nov 10, 2026
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 10, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Nov 10, 2026
clickhouse-gh Bot added a commit that referenced this pull request Nov 10, 2026
Backport #130354 to 26.10: Fix ORC `TIMESTAMP` values before the first time zone transition
clickhouse-gh Bot added a commit that referenced this pull request Nov 10, 2026
Backport #130354 to 26.8: Fix ORC `TIMESTAMP` values before the first time zone transition
clickhouse-gh Bot added a commit that referenced this pull request Nov 10, 2026
Backport #130354 to 26.9: Fix ORC `TIMESTAMP` values before the first time zone transition
Algunenano added a commit that referenced this pull request Nov 11, 2026
Backport #130354 to 26.3: Fix ORC `TIMESTAMP` values before the first time zone transition
leshikus pushed a commit that referenced this pull request Nov 13, 2026
leshikus pushed a commit that referenced this pull request Nov 13, 2026
leshikus pushed a commit that referenced this pull request Nov 13, 2026
leshikus pushed a commit that referenced this pull request Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-formats Input/output formats (CSV/JSON/Parquet/ORC/Arrow/Protobuf/etc.). pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-not-for-changelog This PR should not be mentioned in the changelog 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.

4 participants