Skip to content

Arithmetic operations between DateTime and Time - #82980

Merged
qoega merged 18 commits into
masterfrom
yarik/datetime-time-operations
Aug 31, 2026
Merged

qoega merged 18 commits into
masterfrom
yarik/datetime-time-operations

Conversation

@yariks5s

@yariks5s yariks5s commented Jul 1, 2025 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • New Feature

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

Operations '+' and '-' between DateTime and Time data types.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.9.1.460 (included in 26.9 and later)

@clickhouse-gh

clickhouse-gh Bot commented Jul 1, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [862d1d1]

Summary: ✅


AI Review

Summary

This PR adds +/- support between DateTime/DateTime64 and Time/Time64, including explicit-timezone preservation and date_time_overflow_behavior handling. The follow-up fixes addressed the earlier arithmetic and coverage problems, but the user-facing operator docs are still out of sync with the final behavior, so I would not merge it yet.

Findings

⚠️ Majors

  • [docs/reference/operators/index.mdx:399, docs/reference/data-types/time.mdx:132, docs/reference/data-types/time64.mdx:137] The operator reference still documents the date/time matrix as if only Date/Date32 can be combined with Time/Time64, and both Time pages explicitly send readers there for "all supported combinations and result types." After this PR, users following that documented path will still conclude that DateTime/DateTime64 with Time/Time64 is unsupported, and they still get no operator-level documentation for the new DateTime - Time form. Update the operator docs so the matrix/result-type rules cover the new DateTime/DateTime64 combinations and subtraction behavior as well.
Final Verdict

Changes requested: the implementation looks ready, but the operator/reference documentation is still missing the new DateTime/Time and DateTime64/Time64 behavior.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.50% 86.50% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 78.70% 78.80% +0.10%

Changed lines: Changed C/C++ lines covered: 142/144 (98.61%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label Jul 1, 2025
@scanhex12 scanhex12 self-assigned this Jul 1, 2025
@clickhouse-gh

clickhouse-gh Bot commented Sep 2, 2025

Copy link
Copy Markdown
Contributor

Dear @scanhex12, this PR hasn't been updated for a while. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

Comment thread src/Functions/plus.cpp
It is also possible to add a date and a time. Adding a `Date` and a `Time`
produces a `DateTime`. Adding a `Date` and a `Time64`, or a `Date32` and
a `Time` or `Time64`, produces a `DateTime64`.
Adding a `Time` or `Time64` to a `DateTime` or `DateTime64` applies the time

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The source-level plus/minus descriptions are updated here, but the main user-facing operators docs are still out of sync. docs/en/sql-reference/operators/index.md#date-time-addition currently documents only Date/Date32 + Time/Time64, and both time.md and time64.md point readers there for the full combination matrix. After this change, users following that documented path will still conclude that DateTime/DateTime64 with Time/Time64 is unsupported, so the operators reference should be updated alongside these function docs.

…me/Time arithmetic in operators reference, add DateTime64(9) saturate regression
@mintlify

mintlify Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
ClickHouse-docs 🟢 Ready View Preview Jul 20, 2026, 5:22 PM

@mintlify

mintlify Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
ClickHouse-docs 🟡 Building – Jul 20, 2026, 4:59 PM

@clickhouse-gh

clickhouse-gh Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.20% 86.20% +0.00%
Functions 92.00% 92.00% +0.00%
Branches 78.20% 78.30% +0.10%

Changed lines: Changed C/C++ lines covered: 145/147 (98.64%) · Uncovered code

Full report · Diff report

`master` moved the documentation from the Docusaurus tree under
`docs/en/**/*.md` to the Mintlify tree at `docs/**/*.mdx`, deleting every
file this branch edits. The edits are replayed at the new paths:

Accepted the deletion for pages the migration did not carry over:

- `docs/en/sql-reference/operators/index.md` (no counterpart in the new tree)
@clickhouse-gh

clickhouse-gh Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 862d1d165 with master d0758c6f8 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 48ebef16a; compile times per translation unit against the most recent warmup build that recompiled it).

⚠️ Significant changes: compile time of recompiled translation units.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 688.57 MiB 685.96 MiB -2.61 MiB (-0.38%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Object file sizes

11 object files changed (+150.31 KiB total), 0 added.

Object file Master PR Δ
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/minus.cpp.o 8.38 MiB 8.46 MiB +81.47 KiB (+0.95%)
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/plus.cpp.o 8.65 MiB 8.69 MiB +41.34 KiB (+0.47%)
src/CMakeFiles/dbms.dir/Storages/TimeSeries/PrometheusQueryToSQL/applyAggregationOperatorQuantile.c… 105.54 KiB 132.26 KiB +26.72 KiB (+25.32%)

737 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.

Compile time of recompiled translation units ⚠️

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

Translation units without a recent master baseline:

  • src/Functions/modulo.cpp: 53.4 s
  • src/Functions/intDiv.cpp: 32.0 s
  • src/Functions/divide.cpp: 29.1 s
  • src/Functions/minus.cpp: 20.4 s
  • src/Functions/moduloOrNull.cpp: 19.7 s
  • src/Functions/multiply.cpp: 19.5 s
  • src/Functions/intDivOrZero.cpp: 18.5 s
  • src/Functions/avg2.cpp: 17.8 s
  • src/Functions/midpoint.cpp: 17.8 s
  • src/Functions/moduloOrZero.cpp: 13.8 s
  • src/Functions/bitShiftLeft.cpp: 13.0 s
  • src/Functions/bitShiftRight.cpp: 12.5 s
  • src/Functions/bitBoolMaskOr.cpp: 12.1 s
  • src/Functions/bitBoolMaskAnd.cpp: 12.0 s
  • src/Functions/lcm.cpp: 11.7 s
  • src/Functions/bitOr.cpp: 11.3 s
  • src/Functions/gcd.cpp: 11.3 s
  • src/Functions/bitAnd.cpp: 11.2 s
  • src/Functions/bitXor.cpp: 11.2 s
  • src/Functions/bitRotateLeft.cpp: 11.1 s
  • ... and 3 more

Job report

@clickhouse-gh

clickhouse-gh Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Dear @scanhex12, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

@qoega qoega self-assigned this Aug 31, 2026
@qoega
qoega added this pull request to the merge queue Aug 31, 2026
Merged via the queue into master with commit 27888b9 Aug 31, 2026
353 of 355 checks passed
@qoega
qoega deleted the yarik/datetime-time-operations branch August 31, 2026 19:24
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 31, 2026

This branch was successfully deployed

1 active deployment
staging - docs — 862d1d16 Deployed Aug 5, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

5 participants