Skip to content

Fix misaligned PrettyCompact output in function docs; accept 1-6 digit %f in parseDateTime - #109421

Merged
alexey-milovidov merged 4 commits into
masterfrom
docs-prettycompact-alignment-and-parsedatetime-microseconds
Jul 14, 2026
Merged

alexey-milovidov merged 4 commits into
masterfrom
docs-prettycompact-alignment-and-parsedatetime-microseconds

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jul 5, 2026 •

Copy link
Copy Markdown
Member

Two related fixes discovered while cleaning up the function reference documentation.

1. Misaligned PrettyCompact output in the function documentation examples. Many embedded FunctionDocumentation examples 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 as multiSearchAnyUTF8 looked 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, toDateTime64 saturation, JSONExtractKeysAndValuesRaw number formatting, ...), broken example queries (assumeNotNull selected FROM table instead of FROM t_null, JSONExtractKeysAndValues had its arguments swapped, multiplyDecimal's query did not match its output), and an ASCII | used instead of │ in naturalSortKey.

2. parseDateTime %f now accepts 1 to 6 fractional digits. The MySQL-syntax microsecond specifier %f required exactly 6 digits, so a natural query such as parseDateTime64('2025-01-04 23:00:00.123', '%Y-%m-%d %H:%i:%s.%f') — the very query shown in the documentation — threw CANNOT_PARSE_DATETIME. It now reads between 1 and 6 digits and interprets them as left-aligned microseconds (.123 becomes 123000), matching MySQL's STR_TO_DATE. More than 6 digits, or zero digits, are still rejected. Covered by a new stateless test and updated assertions in 02668_parse_datetime.

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

The MySQL-style format specifier %f in parseDateTime / parseDateTime64 (and their OrZero / OrNull variants) now accepts between 1 and 6 fractional digits, interpreted as left-aligned microseconds like MySQL's STR_TO_DATE, instead of requiring exactly 6. Also fixed misaligned PrettyCompact tables in the built-in function documentation examples.

🤖 Generated with Claude Code

Version info

  • Merged into: 26.7.1.909 (included in 26.7 and later)

…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]>
@clickhouse-gh

clickhouse-gh Bot commented Jul 5, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [a406e0c]

Summary: ✅


AI Review

Summary

I reviewed the %f parsing change in src/Functions/parseDateTime.cpp, the updated stateless coverage in tests/queries/0_stateless/02668_parse_datetime.sql and tests/queries/0_stateless/04502_parseDateTime_variable_length_microseconds.sql, and the surrounding embedded documentation updates. The behavior change is tightly scoped, the regression coverage exercises the new 1-6 digit acceptance and the invalid 0/7-digit cases, and I did not find a correctness, compatibility, or user-facing documentation issue that warrants an inline finding.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Jul 5, 2026
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]>
@yariks5s yariks5s self-assigned this Jul 6, 2026
…ttycompact-alignment-and-parsedatetime-microseconds
@clickhouse-gh

clickhouse-gh Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 79.80% 85.80% +6.00%
Functions 91.70% 92.70% +1.00%
Branches 72.00% 78.00% +6.00%

Changed lines: Changed C/C++ lines covered: 458/459 (99.78%) · Uncovered code

Full report · Diff report

@alexey-milovidov
alexey-milovidov merged commit 7033b8d into master Jul 14, 2026
176 of 177 checks passed
@alexey-milovidov
alexey-milovidov deleted the docs-prettycompact-alignment-and-parsedatetime-microseconds branch July 14, 2026 13:32
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 14, 2026
@clickgapai

Copy link
Copy Markdown
Contributor

Hi @alexey-milovidov @yariks5s — while reviewing this PR I found the following:

Happy to discuss — close anything that's wrong or already addressed.

zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…ct-alignment-and-parsedatetime-microseconds

Fix misaligned PrettyCompact output in function docs; accept 1-6 digit `%f` in parseDateTime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants