Repository navigation
Fix misaligned PrettyCompact output in function docs; accept 1-6 digit %f in parseDateTime - #109421
Conversation
…t `%f` in parseDateTime
Realign the box-drawing tables in the embedded function-documentation examples so
they render correctly in the web docs viewer, regenerating them from the actual
server output with full column headers (no truncation ellipsis). CJK-only examples
(`multiSearchAnyUTF8`, `editDistanceUTF8`, `stringJaccardIndexUTF8`) now alias the
result column to an ASCII name so the box aligns regardless of the browser's CJK
font metrics. This also corrects examples whose stored output no longer matched
the server (`subtractQuarters`, `UUIDv7ToDateTime`, `toDateTime64` saturation,
`JSONExtractKeysAndValuesRaw` number formatting, ...), broken example queries
(`assumeNotNull` referenced a non-existent table, `JSONExtractKeysAndValues` had
its arguments swapped, `multiplyDecimal`'s query did not match its output), and an
ASCII `|` used instead of `│` in `naturalSortKey`.
Additionally, the MySQL-syntax specifier `%f` in `parseDateTime64` (and the
`parseDateTime` / `parseDateTime64OrZero` / `parseDateTime64OrNull` variants) now
accepts between 1 and 6 fractional digits and interprets them as left-aligned
microseconds, matching MySQL's `STR_TO_DATE` (e.g. `.123` is parsed as `123000`
microseconds). Previously exactly 6 digits were required, so the documented example
`parseDateTime64('2025-01-04 23:00:00.123', '%Y-%m-%d %H:%i:%s.%f')` raised an
exception.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Workflow [PR], commit [a406e0c] Summary: ✅
AI ReviewSummaryI reviewed the Final VerdictStatus: ✅ Approve |
The regenerated `formatRow('CustomSeparated', number, 'good')` example
reproduces the real server output, whose field delimiter is a literal
tab (`CustomSeparated` uses `\t` by default, written verbatim by the
`Pretty` formats). The style check forbids literal tabs in source files
unless they are inside an embedded-documentation raw string using the
`R"DOCS_MD( ... )DOCS_MD"` delimiter, which `filter_embedded_docs.py`
exempts. Switch that one example's output literal from `R"( ... )"` to
`R"DOCS_MD( ... )DOCS_MD"` so the faithful output (tab included) passes
the check, matching the convention already used across the codebase.
Style check report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=109421&sha=f111386525231c84309c95b8a646dbcd3b12a1be&name_0=PR&name_1=Style%20check
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…time-microseconds
…ttycompact-alignment-and-parsedatetime-microseconds
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 458/459 (99.78%) · Uncovered code |
|
Hi @alexey-milovidov @yariks5s — while reviewing this PR I found the following:
Happy to discuss — close anything that's wrong or already addressed. |
…ct-alignment-and-parsedatetime-microseconds Fix misaligned PrettyCompact output in function docs; accept 1-6 digit `%f` in parseDateTime
Two related fixes discovered while cleaning up the function reference documentation.
1. Misaligned
PrettyCompactoutput in the function documentation examples. Many embeddedFunctionDocumentationexamples had box-drawing tables whose borders did not line up. Some were hand-written with the wrong number of dashes/spaces (misaligned in any renderer, including a terminal), and CJK examples such asmultiSearchAnyUTF8looked misaligned specifically in the web docs viewer because browser monospace fonts do not render CJK glyphs at exactly twice the ASCII advance. All affected examples were regenerated from the actual server output with full column headers (no truncation ellipsis). CJK-only examples (multiSearchAnyUTF8,editDistanceUTF8,stringJaccardIndexUTF8) alias the result column to a short ASCII name so the box aligns regardless of the font. This also corrected examples whose stored output was stale (subtractQuarters,UUIDv7ToDateTime,toDateTime64saturation,JSONExtractKeysAndValuesRawnumber formatting, ...), broken example queries (assumeNotNullselectedFROM tableinstead ofFROM t_null,JSONExtractKeysAndValueshad its arguments swapped,multiplyDecimal's query did not match its output), and an ASCII|used instead of│innaturalSortKey.2.
parseDateTime%fnow accepts 1 to 6 fractional digits. The MySQL-syntax microsecond specifier%frequired exactly 6 digits, so a natural query such asparseDateTime64('2025-01-04 23:00:00.123', '%Y-%m-%d %H:%i:%s.%f')— the very query shown in the documentation — threwCANNOT_PARSE_DATETIME. It now reads between 1 and 6 digits and interprets them as left-aligned microseconds (.123becomes123000), matching MySQL'sSTR_TO_DATE. More than 6 digits, or zero digits, are still rejected. Covered by a new stateless test and updated assertions in02668_parse_datetime.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The MySQL-style format specifier
%finparseDateTime/parseDateTime64(and theirOrZero/OrNullvariants) now accepts between 1 and 6 fractional digits, interpreted as left-aligned microseconds like MySQL'sSTR_TO_DATE, instead of requiring exactly 6. Also fixed misalignedPrettyCompacttables in the built-in function documentation examples.🤖 Generated with Claude Code
Version info
26.7.1.909(included in26.7and later)