Repository navigation
Update ReadHelpers.h (parse small decimal timestamps correctly) - #86431
egbaydarov wants to merge 104 commits into
Conversation
|
A test? |
|
I found many more corner cases, in same logical part in parsing, in the method |
1681eb9 to
b13e686
Compare
|
I suppose it's done for now. tldr After calling the method: ClickHouse/src/IO/ReadHelpers.h Line 1074 in 3d56dfb the execution may proceed along three distinct paths.
Buffer SemanticsAfter parsing, the buffer may still contain metadata (depending on The current implementation attempts to optimize by avoiding Proposed ModificationISO 8601 parsing should be made more conservative. YYYY-MM-DD This measure prevents most false positives, including small Future WorkIn the longer term, parsing could be refactored with a stricter Current ChangesThe short buffer path has been removed as redundant. The compatible flow is now defined as: a) Attempt ISO 8601 optimistic parse if length is sufficient. The calling method: ClickHouse/src/IO/ReadHelpers.h Line 1074 in 3d56dfb already implements a workaround for decimal Unix timestamps with I was curious and looked for further optimizations to improve both correctness
|
|
Workflow [PR], commit [1a5e828] Summary: ❌
AI ReviewSummaryThe PR fixes small numeric Findings❌ Blockers
Final VerdictStatus: ❌ Block Preserve SQLite's accepted timestamp suffixes and prevent the PostgreSQL |
|
Hi, could one of the maintainers take a look at this PR? |
|
@rienath Hi, it looks like all the tests passed successfully |
|
Dear @yariks5s, 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. |
|
Dear @serxa, 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. |
# Conflicts: # src/Core/PostgreSQL/insertPostgreSQLValue.cpp
…eSQL UTC offset `assertPostgreSQLDateTimeFullyParsed` validated only the shape of the UTC offset suffix, so values like `2025-01-02 03:04:05+03:60` or `+03:30:60` were accepted. PostgreSQL never renders a minutes or seconds group of 60 or more, so reject such values. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…eys in `05217` The test was added on master and expects `CANNOT_PARSE_TEXT` when a `String` like `bad` is converted to a `DateTime` dictionary key. This PR intentionally makes the `DateTime` text parser reject a value starting with a character that can be neither a date nor a timestamp with `CANNOT_PARSE_DATETIME`, instead of leaving the unix epoch and relying on the caller to report trailing characters. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=86431&sha=latest&name_0=PR&name_1=Fast%20test ClickHouse#86431 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged current |
# Conflicts: # src/IO/ReadHelpers.h
… a broken-down date Matching separators at positions 4 and 7 alone let a small decimal `DateTime64` timestamp such as `1234.5` followed by a leading-dot field (`1234.5<TAB>.25`) be read as a `YYYY.MM.DD` date across the field delimiter. Require the digits of the year, month and day as the fallback does, on the throwing path too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rtition literal `convertPartitionFieldToType` classified `'1234.5'` as a broken-down date because of the fifth character, and rejected a value that the parser reads as a unix timestamp. Treat it as a timestamp unless it has the `YYYY.MM.DD` layout, so that the fractional-precision check applies to it. Add a test for both review findings. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=86431&sha=f7c9315f1da2f8f17d2cdc6970b9c78c81d5d064&name_0=PR&name_1=Stateless%20tests%20(amd_debug%2C%20distributed%20plan%2C%20s3%20storage%2C%20parallel) ( |
|
The fix is #126385 (merged 2026-10-20 02:09 UTC). The failed run here was created 2026-10-19 17:36 UTC for f7c9315, before the merge, so its tree did not have the fix. Your new head 56677d6 contains it (its run started 04:50 UTC today). Cause: a113d43 fixed a different race (a build task dropping its partial filter). This one: when the random MergeTree setting Since the merge: 0 failures in 4,186 master runs; the only failure in about 29,000 PR runs was a re-run of a workflow created before the merge. |
…t layout Since 2887cc2 the `DateTime` text parser takes the broken-down date path only when the year, month and day digits are present, so garbage such as `'20/4-03-01 00:00:00'` and `'\0930-12-12 ...'` is now rejected with `CANNOT_PARSE_DATETIME` / `TYPE_MISMATCH` instead of being read as a nonsense date. - `05258_drop_partition_invalid_date_literal`: expect the parser error for `'20/4-03-01 00:00:00'`. - `02269_to_start_of_interval_overflow`: the garbage literal only served to produce a far-out-of-range value; use the valid `'2299-12-31 23:59:59.999'` instead, which still triggers `DECIMAL_OVERFLOW` in `toStartOfInterval` with a nanosecond interval. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=86431&sha=56677d61ee38b0109e19b5dacc51ceb08c588d83&name_0=PR&name_1=Fast%20test PR: ClickHouse#86431 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged current
All 13 stateless |
The Delta protocol permits timestamp partition values such as `2024-01-02T03:04:05.123456Z`. The new `assertEOF` in `DeltaLakeMetadata::getFieldValue` rejected them because `readDateTime64Text` leaves the trailing `Z` unread. Strip a trailing `Z` and parse the value in UTC; other trailing characters are still rejected. Add a regression test for the legacy reader (`allow_delta_kernel_rs = 0`). Co-Authored-By: Claude Opus 5.5 <[email protected]>
`DeltaLakeMetadata.cpp` (the legacy Delta Lake reader) was removed in master, so the PR's change to it and its legacy-only test `05497_delta_lake_legacy_timestamp_partition_utc` are dropped.
Schema inference (`tryInferDateTime`, `tryInferDateTime64`) passes `-/:` as the allowed date delimiters and infers a value like `2024:01:02 03:04:05` as `DateTime`, but the deserializer calls the parser without explicit delimiters, and the default set (`-`, `/`, `.`) rejected it, so a value that is inferred could not be read. Add ':' to the default set in both the optimistic and the fallback paths (the digit-layout checks are kept). Co-Authored-By: Claude Opus 5.5 <[email protected]>
SQLite date and time values may end with `Z` or `[+-]HH:MM` (https://www.sqlite.org/lang_datefunc.html#time_values). They were silently ignored before, but the new end-of-input check rejected them. Accept a well-formed time zone indicator (not applied, as before) and keep rejecting malformed ones and other trailing characters. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ed partition literals like the parser The `DateTime64` text parser recovered from any exception of the whole part when positioned at a dot, which turned malformed values whose date-shaped prefix was consumed across a buffer refill (e.g. `1234.56..78`, `2025-01-.5`) into unrelated timestamps. Leading-dot fractions are handled explicitly by both the optimistic path and the fallback, so the recovery is removed. The partition literal check now classifies a `DateTime`/`DateTime64` literal as a broken-down date with the same digit-layout and sign rule as `readDateTimeTextImpl`, so a signed timestamp like `+123.5` can be used as a partition literal. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…Fallback` Co-Authored-By: Claude Opus 5.5 <[email protected]>
| throw Exception(ErrorCodes::CANNOT_PARSE_DATETIME, "Invalid minutes in the time zone indicator of a date and time value"); | ||
| } | ||
|
|
||
| assertEOF(in); |
There was a problem hiding this comment.
[Blocker] Preserve SQLite's accepted time-zone suffix syntax
This EOF check rejects existing SQLite timestamp values such as 2024-01-02 03:04:05Z , 2024-01-02 03:04:05+00:00 and 2024-01-02 03:04:05z. SQLite accepts all three as the same timestamp: its parseTimezone accepts lowercase z and skips whitespace before and after the indicator. Here only uppercase Z and spaces before the indicator are handled, so selecting these values through a SQLite table declared with DateTime('UTC') now throws CANNOT_PARSE_INPUT_ASSERTION_FAILED; the previous reader accepted them.
Please preserve that suffix grammar before enforcing EOF, including whitespace after the indicator, and extend 05621_sqlite_datetime_time_zone_indicator with these cases. Genuine trailing text should still fail.
| /// rather than waved through as "digits and colons in some order". | ||
| void assertPostgreSQLDateTimeFullyParsed(ReadBuffer & in) | ||
| { | ||
| skipDateTimeFractionalSeconds(in); |
There was a problem hiding this comment.
[Major] Do not skip a second fraction for DateTime64
This helper is also called after readDateTime64Text, which has already consumed the fractional seconds. With a PostgreSQL text value of 1234.5.6, the parser consumes 1234.5, this unconditional call discards .6, and EOF validation succeeds: the imported value is silently 1970-01-01 00:20:34.500. The same happens for 2025-01-02 03:04:05.5.6 and for Array(DateTime64(3, 'UTC')) mapped from PostgreSQL text[].
Only skip fractional seconds for the plain DateTime callers. After a DateTime64 parse, accept only the optional PostgreSQL offset and EOF, and add scalar/array regressions for a second fractional tail.
|
I merged Since 2026-11-19, stateless tests randomize the MergeTree setting 🤖 Generated with Claude Code |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed parsing of small decimal and short numeric
DateTime64strings as Unix timestamps.Details
Closes: #86430
Closes: #118354
Workflow [PR]
Sync PR [sync-upstream/pr/86431]