Skip to content

Web UI: group the digits of a long number with a gap, not an underline - #119839

Merged
alexey-milovidov merged 5 commits into
masterfrom
play-ui-digit-group-separators
Sep 26, 2026
Merged

alexey-milovidov merged 5 commits into
masterfrom
play-ui-digit-group-separators

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Sep 13, 2026 •

Copy link
Copy Markdown
Member

In the Web UI, a long number in the result table was grouped by underlining one digit at each group-of-three boundary, mirroring clickhouse-client. On a proportional page — unlike in a terminal — a gap reads better, and the classic typographic grouping of digits is a thin space: 1 234 567.

A real separator character would be copied along with the number, so the groups are separated by an empty element instead: <span class="num-sep"></span>, an inline-block a quarter of a digit wide (0.25ch, which in the table's monospace font is exactly a quarter of a digit). The gap is painted, but the text of the cell is still nothing but the digits — selecting the number, or copying the cell, yields 1234567.

Digit groups in the Web UI result table, before and after

The same grouping is now applied to the row-number column, whose numbers pass five digits on a later page of a large result.

The digit groups in the query editor are left as they were: its backdrop must match the metrics of the textarea underneath it character for character, so the highlight there cannot change the advance width of anything.

Verified in a browser against a locally built server: the separator measures exactly 0.25 of a digit, the digit columns of a right-aligned number still line up, a selection over a grouped number returns the bare digits, and the grouping also holds in the selected (inverted, wrapping) cell overlay and in the dark theme.

Changelog category (leave one):

  • Improvement

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

In the Web UI, the digits of a long number in the result table are now grouped by a thin gap, as in 1 234 567, instead of an underline. The gap is an empty element, so selecting or copying the number still yields the digits alone.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/119839]

Version info

  • Merged into: 26.10.1.773-master (included in 26.10 and later)

A long number in the result table was grouped by underlining one digit at
each group-of-three boundary, mirroring `clickhouse-client`. In a proportional
page - unlike a terminal - a gap reads better, and the classic typographic
grouping is a thin space: `1 234 567`.

A real separator character would be copied along with the number, so the
groups are separated by an EMPTY element instead - `<span class="num-sep">`,
an inline-block a quarter of a digit wide (`0.25ch`, which in the table's
monospace font is exactly a quarter of a digit). The gap is painted, but the
text of the cell is still nothing but the digits: selecting the number, or
copying the cell, yields `1234567`.

The same grouping is applied to the row-number column, whose numbers pass
five digits on a later page of a large result.

The digit groups in the query editor are left as they are: its backdrop must
match the metrics of the textarea underneath it character for character, so
the highlight cannot change the advance width of anything.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [43147b2]

Summary: ✅


AI Review

Summary

This PR replaces the underlined digit grouping in the Web UI result table with empty separator elements and applies the same grouping to row numbers. The main rendering path looks consistent with the existing implementation, but one edge case still violates the new helper's digits-only contract: row numbers are grouped by string length alone, so scientific-notation offsets can be split in the middle of the exponent.

Findings

💡 Nits

  • [programs/server/play.html:4911] digitGroupsHTML assumes a digits-only input, but the row-number path only checks length. _rowNumberOffset() accepts any finite page and size, and once String(this._rowNumberOffset() + this._row_idx) flips to scientific notation (1e+21 and above), this renders as 1e +21 with a separator inserted into the exponent. Mirror the ^\d{5,}$ guard from _renderCell, or otherwise normalize row numbers before calling digitGroupsHTML.
Final Verdict

Left one non-blocking inline comment on the row-number grouping edge case; otherwise the change looks sound.

LLVM Coverage Report

Measured on commit 43147b2.

Metric Baseline Current Δ
Lines 88.20% 88.20% +0.00%
Functions 91.80% 91.70% -0.10%
Branches 79.50% 79.50% +0.00%

Changed lines: Uncovered code analysis did not run: No coverable C/C++ source files changed (contrib/ is excluded from coverage).

Newly covered: +185 lines in 56 files (-135 lines lost coverage) · Details

Full report

@clickhouse-gh clickhouse-gh Bot added pr-improvement Pull request with some product improvements comp-protocols Server wire protocols + request/response handling (native TCP, HTTP, MySQL/PostgreSQL wire protoc... labels Sep 13, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Commit 43147b23f728b2e0bf66232422184f9e3a820438 was not compared: the CI logs cluster did not answer (every POST attempt failed with an exception).

See the job log for details.

alexey-milovidov and others added 2 commits September 19, 2026 08:56
The number 05210 has been taken by many tests that landed on master while this
branch was waiting, so the Web UI digit-grouping test moves to the next free
number.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failures and provide a fix in a separate PR (link it here if one is already in progress):

Both are server-side logical errors, and this pull request changes only programs/server/play.html and two stateless tests, so neither can be caused by it.

@groeneai

Copy link
Copy Markdown
Collaborator

Both are pre-existing, and neither can come from this PR.

1. Invalid number of columns in chunk pushed to OutputPort (STID 2270-38be): fixed by #119728, merged today at 04:30 UTC

The header names the cause: s AggregateFunction(countResample(10, 5, 1), UInt64, UInt64) AggregateFunction(size = 0). -Resample over an empty range (begin >= end) serializes its nested states with no framing and holds none over that range, so every state occupies zero bytes and the state column reads back as zero rows. That is the expected 2 / found 1 chunk: Chunk: UInt64(size = 100) is k alone. #119727 documents the same zero-byte state making a StripeLog table permanently unreadable, and Set and Join tables unattachable.

#119728 rejects that parameterisation where the function is created, and the state type with it, so no query can build such a column any more.

  • Your failing head f44b3107 is 3369 commits behind the fix's merge commit 5ea18126, so it never carried it. Your current head 349b3086 (the 08:58 UTC master merge) does contain it, so this failure should not recur there.
  • All 66 rows of this STID in CIDB over the last 14 days carry that identical countResample(10, 5, 1) header, across 56 pull requests plus 6 master and 2 26.9 rows, so the signature has a single cause and the merge should retire all of it. Onset was 2026-09-13, peaking at 24 rows on 09-14.
  • Nothing has fired since the merge, but at 5 to 11 rows a day that is five hours of evidence rather than proof, so I will keep watching it and report here if it recurs at a head that contains the fix.

2. Query builder not found for text search query with function 'equals' (STID 3694-54bc): not fixed on master, and I am measuring the in-flight candidate now

The fuzzed query is SELECT count(str) FROM tab__fuzz_7 FINAL PREWHERE str = '(' WHERE str = 'bar', where str carries a text index. Every occurrence with a recorded query has the same shape: two different text-search predicates on one text-indexed column, one in PREWHERE and one in WHERE (equals / equals here, has / has, hasAllTokens / has and hasAllTokens / hasToken before). AST fuzzer only so far: 11 rows over 6 pull requests in 90 days, none on master.

On the two candidate PRs, so that I do not link a coincidental one:

What I have not measured is whether #114242 covers this particular instance (equals, FINAL, tokenizer = array). I am building that check now. If it does, I will say so here; if it does not, I will open a separate PR with a regression test and link it here.

@groeneai

Copy link
Copy Markdown
Collaborator

2. Query builder not found for text search query with function 'equals' (STID 3694-54bc): fixed in #121041

Resolving the conditional above: this is not the distributed-plan route, so #114242 could not cover it and I did not spend a build on it. That draft is still at 8343985bd3d7 from 2026-09-04 and touches neither MergeTreeReaderTextIndex nor TextIndexAnalyzer.

Root cause: for non-intersecting parts, optimizeLazyFinal builds its own reading step and copies the original step's text index read tasks, but re-derives its skip index conditions from the WHERE filter alone. Its granule then carries query builders only for the WHERE predicate while the reader looks up the inherited PREWHERE one, so getQueryBuilder refuses a hash it never registered. Identical predicates hash the same, which is why only different ones expose it.

#121041 accepts a granule only when its analyzer covers this reader's own search queries, and otherwise reads the granule from the reader's own condition. The logical error itself stays: it removes the violation, not the check.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failures and provide a fix in a separate PR (link it here if one is already in progress):

Both are in refreshable materialized views, and this pull request changes only programs/server/play.html and two stateless tests, so neither can be caused by it. Neither has an open issue. What I found while attributing them, in case it saves you the first pass:

1. uuid != UUIDHelpers::Nil && ... (STID 2508-49e2): a Nil parent-table UUID reaching tryGetByUUID

The stack is RefreshTask::executeRefreshUnlocked → StorageMaterializedView::prepareRefresh → InterpreterCreateQuery::createTable → DatabaseReplicated::tryEnqueueReplicatedDDL → DatabaseReplicatedDDLWorker::tryEnqueueAndExecuteEntry → checkParentTableExists → DatabaseCatalog::tryGetByUUID.

RefreshTask::executeRefreshUnlocked calls refresh_context->setParentTable(view_storage_id.uuid) unconditionally for a non-append refresh (src/Storages/MaterializedView/RefreshTask.cpp:1349). The value goes onto the DDL entry as an std::optional<UUID>, so entry.parent_table_uuid.has_value() is true even when the UUID is UUIDHelpers::Nil, and DatabaseReplicatedWorker.cpp:506 then hands Nil to tryGetByUUID, whose first statement is chassert(uuid != UUIDHelpers::Nil && ...) (src/Interpreters/DatabaseCatalog.cpp:461). The same unguarded call is at DatabaseReplicatedWorker.cpp:728. A view with no UUID of its own — the target database being Replicated while the view itself is not in an Atomic/Replicated one — would take that path.

CIDB, 30 days: 4 rows, all on pull requests (this one, #118830 on 2026-09-12, #116538 and #115489 on 2026-08-26), none on master, so the signature is rare and long-standing rather than new.

2. Segmentation fault (STID 1805-2619): RefreshTask::startup reads view outside the mutex

The stack is DatabaseOrdinary::startupTableAsync → StorageMaterializedView::startup → RefreshTask::startup → WithContextImpl<std::shared_ptr<Context>>::getContext, i.e. a null this inside the getContext call.

RefreshTask::startup dereferences view three times — view->getContext(), view->getTargetTableId(), view->getStorageID() (src/Storages/MaterializedView/RefreshTask.cpp:329-332) — and only then takes mutex. RefreshTask::shutdown sets view = nullptr under that same mutex (RefreshTask.cpp:398). Startup runs on the async loader, so a DROP or a server shutdown concurrent with table startup — exactly what the stress test manufactures — nulls view between the check-free reads, and view->getContext() faults. shutdown already treats view == nullptr as "already shut down"; startup has no such guard.

CIDB, 180 days, matching the stack text rather than the STID: 2 rows, this one and #108345 on 2026-06-24 — also a Web-UI-only pull request of mine, which is itself evidence that the crash is independent of what the pull request changes.

@groeneai

Copy link
Copy Markdown
Collaborator

Both signatures already have a fix PR in flight.

1. uuid != UUIDHelpers::Nil && getFirstLevelIdx(uuid) < uuid_map.size() (STID 2508-49e2): #111928

The amd_msan row at 349b3086 carries exactly the chain you describe: RefreshTask::executeRefreshUnlocked (RefreshTask.cpp:1360) -> StorageMaterializedView::prepareRefresh -> InterpreterCreateQuery::createTable -> DatabaseReplicated::tryEnqueueReplicatedDDL -> tryEnqueueAndExecuteEntry (DatabaseReplicatedWorker.cpp:506) -> checkParentTableExists (:803) -> tryGetByUUID (DatabaseCatalog.cpp:463).

#111928 addresses both halves of it:

  • The Nil guard goes into checkParentTableExists itself (if (uuid == UUIDHelpers::Nil) return false;, mirroring the guard already in getRMVCoordinationInfo), so it also covers the second call site you point at, DatabaseReplicatedWorker.cpp:728.
  • The Nil UUID should not exist in the first place. A non-APPEND refreshable view is only supported in Atomic and Replicated databases, and CREATE rejects the rest in validateMaterializedViewColumnsAndEngine; that call is gated on mode <= LoadingStrictnessLevel::CREATE, so a full-definition ATTACH MATERIALIZED VIEW ... REFRESH ... TO ... and a RESTORE of a view that had a UUID both bypass it and leave a view whose StorageID UUID is Nil, which is the value setParentTable then writes onto the DDL entry. The PR hoists that check into createTable behind a fresh-definition predicate. In release builds, where the assertion is compiled out, the same state makes the refresh fail permanently with a misleading TABLE_IS_DROPPED: Parent table doesn't exist.

Your frequency reading holds over 90 days as well: 6 rows, 6 unrelated PRs, 4 different jobs (amd_msan, amd_tsan, arm_tsan, BuzzHouse amd_msan), none on master.

2. Segmentation fault (STID 1805-2619): #121037

I opened #121037 from this exact report on 19 September, and the attribution matches yours. Address: 0x158 is a null this plus the offset of WithContextImpl::context, so view was null rather than dangling. shutdown() nulls view under mutex and is documented as callable before or in parallel with startup(), while startup() read view three times before taking that mutex. The fix does startup()'s state work under the mutex, and moves the dependent notification out of RefreshSet::emplace to its one caller after the unlock, because notifyDependents ends in notify() on another task's mutex. It carries a unit test that aborts on the merge-base binary and passes with the change.

Both PRs are open against master and awaiting review.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Thanks @groeneai — noted #111928 (STID 2508-49e2) and #121037 (STID 1805-2619) as the in-flight fixes. Master was merged into this branch on 2026-09-26 (head 43147b23f728) and CI is re-running. The reds on the previous head 08bf78aae48d (Stress arm_debug Got read request from replica A for unknown stream B STID 5217-505b, BuzzHouse amd_msan Bad cast STID 3520-704a, Build profile diff) are server-side too and cannot come from this play.html-only change; I will look again once the fresh run finishes.

Comment thread programs/server/play.html
/// Numbered within the whole result, not within the page (see `_rowNumberOffset`).
td.appendChild(document.createTextNode(this._rowNumberOffset() + this._row_idx));
const row_number = String(this._rowNumberOffset() + this._row_idx);
if (row_number.length >= 5) { td.innerHTML = digitGroupsHTML(row_number); }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

digitGroupsHTML documents a digits-only input, but this path only checks length. sanitizePagination / _goToPage accept any finite page value, so once String(this._rowNumberOffset() + this._row_idx) flips to scientific notation (1e+21 and above), this renders as 1e<span class="num-sep"></span>+21. Could we gate row numbers with the same ^\d{5,}$ check as _renderCell, or otherwise normalize them before calling digitGroupsHTML?

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alexey-milovidov alexey-milovidov self-assigned this Sep 26, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 26, 2026
Merged via the queue into master with commit 934e392 Sep 26, 2026
177 checks passed
@alexey-milovidov
alexey-milovidov deleted the play-ui-digit-group-separators branch September 26, 2026 21:48
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 26, 2026
nihalzp pushed a commit to nihalzp/ClickHouse that referenced this pull request Oct 3, 2026
Each query copied only 5 million rows and finished in ~20 ms, so the
performance comparison measured memory-bandwidth jitter: query ClickHouse#4
(`FixedString` verbatim copy) was flagged as a confirmed slowdown on
`master` itself (2026-09-17) and on unrelated pull requests (ClickHouse#119839,
ClickHouse#110613), and queries ClickHouse#2..ClickHouse#4 moved 11-17% together in one run.
Process 20 million rows, so each query takes ~100 ms.

Report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=110613&sha=dbef7b1548eb9998ee9556d003008cd13d3bffee&name_0=PR&name_1=Performance%20Comparison%20%28arm_release%2C%20master_head%2C%204%2F6%29
PR: ClickHouse#110613

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@clickhouse-gh clickhouse-gh Bot added comp-web-ui Web UI embedded in the server: Play, the dashboards, the merges and processors visualisers, the w... and removed comp-protocols Server wire protocols + request/response handling (native TCP, HTTP, MySQL/PostgreSQL wire protoc... labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-web-ui Web UI embedded in the server: Play, the dashboards, the merges and processors visualisers, the w... 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.

3 participants