Repository navigation
Range-check an integer constant converted to DateTime64 or Time64 - #118656
Conversation
```sql SELECT count() FROM t64 WHERE dt = toUInt64(18446744073709551615); -- 0 SELECT count() FROM t64 WHERE dt IN (toUInt64(18446744073709551615)); -- 1, a row at 1969-12-31 23:59:59 SELECT count() FROM t64 WHERE dt NOT IN (toUInt64(18446744073709551615)); -- 2 of 3 rows, one is lost ``` The `DateTime64` and `Time64` branches of `convertFieldToTypeImpl` funnelled the constant through `FieldVisitorConvertToNumber<Int64>`, whose `UInt64` arm is a plain `T(x)`, so a value that does not fit `Int64` wrapped to a negative tick count and built a set that matches an unrelated pre-epoch row. PR #118367 fixed this class for `DateTime`; these two branches were left over, as its review noted. The number of whole seconds is now range-checked, and its multiplication by the scale is checked for overflow, so a constant that no `DateTime64` or `Time64` value can equal yields Null and stays out of the set and out of a key range - which is what `=` computes on the same data. Closes: #118437 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Workflow [PR], commit [1c359be] Summary: ❌
AI ReviewSummaryThis PR range-checks whole-second Final Verdict
LLVM Coverage ReportMeasured on commit 1c359be.
Changed lines: Changed C/C++ lines covered: 21/21 (100.00%) · Uncovered code |
Build profile diff (arm_release)Comparing commit See the job log for details. |
`convertFieldToType` also materializes a value in `values`, where an unrepresentable constant is reported as `ARGUMENT_OUT_OF_BOUND` rather than stored as a wrapped tick count. The scale-dependent bound is covered too, and an in-range constant still materializes. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Addressed: |
…ange-check-118437
Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118656&sha=79247c484e62517c458b92a738b1e9af876950ce&name_0=PR&name_1=Upgrade%20check%20%28amd_release%29 and provide a fix in a separate PR. If the fix is already in progress, link it here. The Upgrade check reports |
|
Not caused by your change. The fix is already open: #118499 (from 2026-09-07, not yet reviewed). There is no issue for this, so that PR is the tracker. Your artifact pins the arm precisely. The table is Mutation selection wins a startup race against cleanup. #118499 skips a zero row part in On the attribution: since 2026-09-08 the CI DB has 36 Upgrade check rows with this message across 34 distinct pull requests and 0 non-PR runs, so 79247c4 is one carrier of many. |
…s-out-of-column-type-range The only conflict is in `src/Interpreters/convertFieldToType.cpp`: master landed `convertWholeSecondsToDateTimeType` (#118656), which range-checks a `UInt64`/`Int64` constant and the scale-up for `DateTime64` and `Time64` the same way this branch did. Take master's version; the tests of this branch keep covering the behavior.
Since the master merge that took master's `convertWholeSecondsToDateTimeType` (#118656), this PR does not change `convertFieldToType` at all. The tests `05055_datetime64_integer_bound_scale_overflow`, `05223_time64_integer_bound_scale_overflow` and the added `ConvertFieldToTypeStrictness` gtests only pin master's behavior (already covered by master's `05218_datetime64_in_set_out_of_range_constant`), so they pass on master and make "Bugfix validation" red. Keep the PR scoped to `WITH FILL`: `04657_with_fill_bounds_out_of_column_type_range` is the regression test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes: #118437
Related: #118367
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
An out-of-range integer constant in an
INset for aDateTime64orTime64column no longer wraps to a negative timestamp and matches an unrelated row.Description
The
DateTime64andTime64branches ofconvertFieldToTypeImplfunnelled the constant throughFieldVisitorConvertToNumber<Int64>, whoseUInt64arm is a plainT(x), so a value that does not fitInt64wrapped to a negative tick count. #118367 fixed this class forDateTime; these two branches were left, as noted in its review.The number of seconds is now range-checked, and the multiplication by the scale is checked for overflow, so a constant no
DateTime64/Time64value can equal yields Null and stays out of the set and out of a key range - which is what=computes on the same data.Workflow [PR]
Sync PR [sync-upstream/pr/118656]