Repository navigation
Fix inserting into Time data type during JSON parsing - #102690
Conversation
|
Workflow [PR], commit [24de88d] Summary: ❌
AI ReviewSummaryThis PR makes Findings
Final Verdict
|
…:ClickHouse/ClickHouse into json-time-type-read
| return false; | ||
| } | ||
|
|
||
| value = element.isInt64() ? element.getInt64() : element.getUInt64(); |
There was a problem hiding this comment.
DateTime conversion here still inserts into ColumnDateTime (UInt32) without range handling, so positive Int64 values above 4294967295 will wrap instead of being clamped/rejected.
Concrete trace: for {"t": 5000000000} as Int64, this branch sets value = 5000000000, then ColumnDateTime::insert stores static_cast<UInt32>(5000000000) = 705032704 (unexpected timestamp around 1992-05-05).
Please align this path with convertFromTime<DataTypeDateTime> semantics (clamp to MAX_DATETIME_TIMESTAMP or throw according to overflow policy) before insert.
There was a problem hiding this comment.
This is still live on the current HEAD.
DateTimeNode now accepts signed JSON integers, but it still inserts directly into ColumnDateTime (UInt32) without range handling:
value = element.isInt64() ? element.getInt64() : element.getUInt64();
assert_cast<ColumnDateTime &>(column).insert(value);For {"t": 5000000000}, this stores 5000000000 mod 2^32 = 705032704 instead of rejecting the out-of-range value (or clamping consistently). Can we add explicit bounds handling before insert (for example via accurate::convertNumeric to UInt32)?
| SELECT 'DateTime64 from Int64 numeric'; | ||
| SELECT JSONExtract('{"t": 1234567890123}', 't', 'DateTime64(3)') SETTINGS date_time_output_format = 'iso'; | ||
|
|
||
| -- Large UInt64 value that is genuinely UInt64 (> INT64_MAX) for DateTime |
There was a problem hiding this comment.
The comment says > INT64_MAX, but 4294967295 is below INT64_MAX. That makes the test intent misleading.
Please reword this to match the actual boundary being tested, e.g. UInt32 max for DateTime.
There was a problem hiding this comment.
This is still inaccurate in the current diff: 4294967295 is not > INT64_MAX; it is exactly UInt32 max.
Please reword the comment so the boundary being tested is clear (for example, "DateTime upper boundary (UInt32 max)").
LLVM Coverage Report
Changed lines: 77.78% (7/9) | lost baseline coverage: 2 line(s) · Uncovered code |
|
Hi @Avogar @yariks5s — while reviewing this PR I found the following:
Could you review the test PR and add the |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix inserting into Time data type during JSON parsing. Closes #102016
Documentation entry for user-facing changes
Version info
26.5.1.683