Repository navigation
Fix setting ignored for numeric-to-DateTime64/Time64 casts - #100535
ai-mountain wants to merge 58 commits into
Conversation
|
Workflow [PR], commit [e7acc30] Summary: ❌
AI ReviewSummaryThis PR threads Findings
Tests
Final Verdict
LLVM Coverage ReportMeasured on commit e7acc30.
Changed lines: Changed C/C++ lines covered: 239/255 (93.73%) · Uncovered code |
0c9fc33 to
1d4b032
Compare
1d4b032 to
afa6e33
Compare
|
@yariks5s |
|
@rschu1ze @alexey-milovidov @yariks5s |
|
@RenzoMXD I will check your PR soon, there are a lot of PRs to check, so it can sometimes take some time to review pull requests. Anyway, I remember about your pr and will check it.🙂 |
|
@RenzoMXD Thanks for the contribution(s). There is generally no need to ping random people, all PRs get eventually reviewed (it may just take a while). |
|
Hi, @yariks5s. Sorry for interrupting you. |
|
@RenzoMXD In general, it is really not needed to ask for new reviews once a day. This creates a false sense of urgency and priority on our end. |
|
Hi, @yariks5s @alexey-milovidov @rschu1ze |
|
The Stress test (arm_msan) failure is fixed by #101239, which should be merged first. After it is merged, please update the branch to include the fix. |
|
@alexey-milovidov Please give me any advice for this failure. |
|
The failures of "Flaky check" in "functions_bad_arguments" will be fixed by #101994. |
|
🕵 Pass 2026-09-06:
|
|
@yariks5s Like to check this PR again? Thanks. |
…ow-behavior Master independently landed exact-tick saturation for `DateTime64` / `Time64` (the `maxTicksForDateTime64` / `minTicksForDateTime64` / `maxTicksForTime64` helpers and integer sources saturating to the last tick, not the whole second). Resolution: master's helpers in `DateTimeTransforms.h`; this branch's bodies of `ToDateTime64TransformFloat` / `ToTime64TransformFloat` (they keep the exact-tick `throw` check via `floatSecondsToTicks` and the up-front non-finite rejection); master's wide-integer and `UInt32 -> Time64` dispatch entries with this branch's `date_time_overflow_behavior` template argument applied to them as well; master's `01734_datetime64_from_float.reference` (integer sources saturate to the exact tick now too). Co-Authored-By: Claude Fable 5.1 <[email protected]>
…o `DateTime64` follow the accurate-cast contract
The `Date32 -> DateTime64` branch of `createDecimalWrapper` dispatched purely by
`date_time_overflow_behavior`, so `accurateCastOrNull(toDate32('9999-12-31'), 'DateTime64(9)')`
returned the saturated `2262-04-11 23:47:16.854775807` under `ignore` / `saturate` instead of
NULL, and `accurateCast` only threw when the session was already on `throw`.
`accurateCast` now dispatches the transform with `Throw`; `accurateCastOrNull` uses a new
file-local `convertDate32ToDateTime64OrNull` that yields NULL for a day whose midnight does
not fit the scale-dependent whole-second window (the same check as `ToDateTime64Transform`).
The plain `CAST` keeps following the setting.
Test `05218_accurate_cast_date32_to_datetime64` covers a materialized `Date32` column at
scale 9 under all three overflow modes, constants, scales 3 and 8, and the plain `CAST`.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ster routes into the transforms Master now dispatches `(U)Int128` / `(U)Int256` sources into `ToDateTimeTransform64*`, `ToDateTime64Transform*` and `ToTime64Transform*`; with this PR passing the real `date_time_overflow_behavior` the `Throw` instantiations are compiled for them too. `wide::integer` has no `fmt` formatter, so format the value with `toString`. `ToDateTime64TransformUnsigned` also compared `static_cast<UInt64>(from)` in its `Throw` branch, which truncates a wide value above `UInt64::max` into one that passes the check (and the following implicit narrowing was ambiguous for wide integers). Compare with `accurate::greaterOp` in the source domain, like the non-throwing branch already does. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…er the merge Master made integer sources saturate `DateTime64` / `Time64` to the last representable tick (`.999...`) rather than the last whole second, so the branch's whole-second assertions in `04402_datetime64_extended_range_review_fixes` and `04403_totime64_saturate_clamp` are replaced with master's forms (this PR keeps only its float exact-boundary and `throw` assertions in 04402), and the upper saturation lines of `04145_date_time_overflow_behavior_numeric_to_datetime64` are re-recorded from `23:59:59.000` to `23:59:59.999`. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
🕵 Pass 2026-09-15:
|
|
📊 Cloud Performance Report
This PR changes CAST conversions to DateTime64, Time64, Date and Time: accurateCast/accurateCastOrNull checks, handling of the overflow-behavior setting, and range checks for float inputs. None of the benchmarked ClickBench or TPC-H queries runs these paths in a meaningful way. ClickBench Q33 (-10.1%) and Q34 (-6.8%) only show as not_sure because master's own baseline moved to a new level on 2026-10-08, which leaves their baselines unstable. Neither delta should be credited to this change, and nothing here needs action. clickbenchFlagged queries (2 of 43)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_official🟢 No significant changes Debug info
|
…rces `05042_datetime64_saturate_to_max_tick` and `05156_big_integer_to_datetime_overflow` landed on master asserting that numeric -> `DateTime`/`DateTime64`/`Time64` conversions saturate even under `date_time_overflow_behavior = 'throw'`, which both tests described as a pre-existing gap. That gap is exactly what this PR fixes, so the conversions now throw `VALUE_IS_OUT_OF_RANGE_OF_DATA_TYPE`. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=100535&sha=2027f62411b9b7f6604bbde14fecfa1b504ff68e&name_0=PR&name_1=Fast%20test PR: ClickHouse#100535 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
🕵 Merged current |
…o fix-datetime-overflow-behavior
…ur `date_time_overflow_behavior` for `Enum` sources `floatSecondsToTicks` truncated the scaled value into an `Int128`. That conversion goes through `long double`, which is emulated in software on AArch64, so `toDateTime64(<Float64>, 3)` became ~50% slower in the `add_days_fixed_offset` performance test (queries 4-6, arm_release). Range-check the scaled `Float64` against [-2^63, 2^63) instead and truncate straight into `Int64`, which is well defined there. `FunctionConvert` dispatched `Enum8`/`Enum16` -> `DateTime`/`Date` with the default overflow mode, so `toDateTime(<Enum8 'neg' = -1>)` ignored `date_time_overflow_behavior = 'throw'` while the `Int8` source honoured it. Route `Enum` sources through the overflow-aware dispatch too, and update the master test `05238_enum_to_datetime_overflow` that pinned the gap. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=100535&sha=c9b7ddfb2c9160c9e56e25e0ea69088ec27fd3b6&name_0=PR&name_1=Performance%20Comparison%20%28arm_release%2C%20master_head%2C%204%2F6%29 PR: ClickHouse#100535 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…me64`, route `DateTime64 -> Time64` through `ConvertImpl` - `accurateCast`/`accurateCastOrNull` from a floating-point number now reject a value whose fractional part is finer than the target scale (`accurateCast(1.1::Float64, 'DateTime64(0)')`, like `1.1` for `DateTime`). Both casts now use the file-local `convertNumberToDateTime64OrTime64Accurate`. - Decimal sources (including `DateTime64 -> DateTime64`) get the same exactness gate as the generic accurate decimal-to-decimal conversion before `tryConvertDecimals`, which silently drops extra fractional digits. - `DateTime64 -> Time64` is the local time of day, not a decimal rescale: the accurate casts go through its dedicated `ConvertImpl` branch again instead of range-checking the raw epoch ticks. Test `05315_accurate_cast_datetime64_time64_exactness`; `05076` narrowed `.999` to scale 1, now uses `.900`. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
🕵 Merged master (5634 commits, no conflicts) and pushed
Local run: all |
…urate `DateTime64 -> Time64` `accurateCastOrNull` still range-checked the raw epoch ticks of the source against `Time64` with `tryConvertDecimals`, so any source later than `MAX_TIME_TIMESTAMP` seconds after the epoch returned `NULL` instead of its time of day. The result is the local seconds-of-day, which is always within the `Time64` range, so the range gate is dropped. The only way the accurate casts can lose information is by dropping sub-second digits when the target scale is narrower than the source scale. Both `accurateCast` and `accurateCastOrNull` now reject such inputs, the same as the `Time64 -> Time64` and `Time64 -> DateTime64` accurate paths. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=100535&sha=c4d59727bef6c3d475f205866c73de5913bd735d&name_0=PR&name_1=AST%20fuzzer%20%28amd_release%2C%20oracle%29 ( |
|
I reproduced it: this is a real wrong result in partition pruning, not an oracle false positive. The CREATE TABLE t (a Array(String)) ENGINE = MergeTree PARTITION BY a ORDER BY tuple();
INSERT INTO t VALUES (['x']), (['y']), (['x', 'z']);
SELECT count() FROM t WHERE NOT (a > [NULL]); -- 0
SELECT count() FROM t WHERE NOT (a > [NULL]) SETTINGS use_partition_pruning = 0; -- 3Same result on 26.3.33.24 and 26.8.2.3. No fix is in progress: #118944 looks for a nested |
|
Fixing PR: #124700 |
|
Dear @yariks5s, 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. |
|
🕵 Closing as superseded: the issue this PR targets, #100471, was fixed on Evidence (base
The remaining differences are deliberate choices on
Merging master into this branch would conflict with both conversion files and 10 tests, and keeping this PR's version would override those decisions. If you want any of these semantics (for example, strict exactness in |
Fix
date_time_overflow_behaviorsetting being ignored when casting numeric types (Int64, UInt64, Float64) toDateTime64/Time64. The setting was silently clamping values instead of throwingVALUE_IS_OUT_OF_RANGE_OF_DATA_TYPEwhen set tothrow.Two root causes:
In
ConvertImpl::execute(FunctionsConversion.h), 15 conversion branches passed the hardcodeddefault_date_time_overflow_behavior(Ignore) instead of the template parameterdate_time_overflow_behaviorto the transform structs. This broke thetoDateTime64/toTime64runtime path.In
FunctionCast::createDecimalWrapper(FunctionsConversion.cpp),ConvertImplwas called without specifying the overflow behavior template parameter, always defaulting toIgnore. This broke theCAST(... AS DateTime64)path, including constant-folded expressions.Fixes #100471
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
date_time_overflow_behaviorsetting being ignored for numeric-to-DateTime64/Time64conversions viaCAST,toDateTime64, andtoTime64.Documentation entry for user-facing changes
No documentation changes needed — this is a bug fix for existing documented behavior.
Workflow [PR]
Sync PR [sync-upstream/pr/100535]