Add precision as parameter for format readable functions by antoniofilipovic · Pull Request #104648 · ClickHouse/ClickHouse · GitHub
Skip to content

Add precision as parameter for format readable functions#104648

Merged
rschu1ze merged 13 commits into
ClickHouse:masterfrom
antoniofilipovic:afilipovic-add-precision-param-format-readable-funcs
May 22, 2026
Merged

Add precision as parameter for format readable functions#104648
rschu1ze merged 13 commits into
ClickHouse:masterfrom
antoniofilipovic:afilipovic-add-precision-param-format-readable-funcs

Conversation

@antoniofilipovic

@antoniofilipovic antoniofilipovic commented May 11, 2026

Copy link
Copy Markdown
Contributor

Closes: #61549

The formatReadableSize, formatReadableDecimalSize and formatReadableQuantity functions previously hard-coded two digits after the decimal point. This PR adds an optional const UInt8 as the second argument precision:

SELECT formatReadableSize(192851925);      -- 183.92 MiB    (unchanged)
SELECT formatReadableSize(192851925, 0);   -- 184 MiB
SELECT formatReadableSize(192851925, 4);   -- 183.9179 MiB

The default of 2 preserves prior behavior, so the change is fully backward compatible. The argument is validated as a constant UInt8, which rejects negative numbers. Also, non-constant columns are rejected.

Changelog category (leave one):

  • New Feature

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

User can now specify an optional precision argument to the formatReadableSize, formatReadableDecimalSize and formatReadableQuantity functions, controlling the number of digits after the decimal point. Default is 2, preserving the prior behavior.

Version info

  • Merged into: 26.6.1.90

@CLAassistant

CLAassistant commented May 11, 2026

Copy link
Copy Markdown

@nikitamikhaylov nikitamikhaylov added the can be tested Allows running workflows for external contributors label May 11, 2026
@antoniofilipovic

Copy link
Copy Markdown
Contributor Author

@rschu1ze thanks for taking a look! 😄

@clickhouse-gh

clickhouse-gh Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [d2720eb]

Summary:

job_name test_name status info comment
Stateless tests (amd_tsan, parallel, 2/2) FAIL
04103_user_network_bandwidth_throttler FAIL cidb IGNORED
Finish Workflow FAIL
python3 ./ci/jobs/scripts/workflow_hooks/check_report_messages.py FAIL IGNORED

AI Review

Summary

This PR adds an optional constant precision argument to formatReadableSize, formatReadableDecimalSize, and formatReadableQuantity, preserves the default behavior when omitted, validates argument shape/type, and adds focused stateless coverage for normal usage and boundary/error cases. I did not find unresolved correctness, safety, or contract issues in the current diff.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label May 11, 2026
Comment thread src/Functions/formatReadable.h
@rschu1ze rschu1ze self-assigned this May 11, 2026
Comment thread src/Functions/formatReadable.h
Comment thread src/Functions/formatReadable.h Outdated
@antoniofilipovic antoniofilipovic marked this pull request as ready for review May 13, 2026 16:05
@alexey-milovidov

This comment was marked as resolved.

Comment thread src/Functions/formatReadableSize.cpp Outdated
Comment thread src/Functions/formatReadable.h Outdated
Comment thread src/Functions/formatReadable.h Outdated
@antoniofilipovic antoniofilipovic force-pushed the afilipovic-add-precision-param-format-readable-funcs branch from 9138ab1 to eeea088 Compare May 19, 2026 23:00
Comment thread src/Functions/formatReadable.h Outdated
@rschu1ze

Copy link
Copy Markdown
Member

@groeneai Make yourself useful (and Nvidia stocks go up) and fix 01563_distributed_query_finish, 02435_rollback_cancelled_queries, 02345_implicit_transaction

@groeneai

Copy link
Copy Markdown
Contributor

@rschu1ze attribution and plan for the three tests:

02435_rollback_cancelled_queries — fix PR #105474. The 20 hits in 30 days are all on Stateless tests (arm_asan_ubsan, targeted) with stdout already correct (1000000\n0) and stderr full of ==NNNN==WARNING: ptrace appears to be blocked ... Child exited with signal 36. The test SIGKILLs clickhouse-client mid-INSERT; LSan's at-exit ptrace tracer cannot attach under the targeted runner's seccomp filter, falls back to SIGRTMIN+2, and the stderr warning trips Praktika's stderr-fatal watch. Setting LSAN_OPTIONS=detect_leaks=0 in the test makes the spawned clients skip the leak scan — running it on a process we are killing on purpose is not useful.

01563_distributed_query_finish — deferred to @Algunenano's open PR #105457. His approach is materially better than what I had drafted: wrap the loop in SYSTEM STOP/START DISTRIBUTED SENDS so the CI system.*_log_sender Distributed tables (set up by ci/jobs/scripts/functional_tests/setup_log_cluster.sh) stop shipping .bin files for the duration of the test. That kills the actual source of the background NETWORK_ERROR bursts (the cloud log endpoint being unreachable) instead of changing the measurement, and it preserves the bug-detection intent exactly. I won't open a competing PR.

02345_implicit_transaction — needs a server-side change. The failure is Code: 159 ... Timeout exceeded (180 s) while flushing system log and the 180 is a hardcoded const int timeout_seconds = 180 in SystemLogBase.cpp:164 (comment already notes 60s proved to be too fast for our parallel functional tests). SET receive_timeout doesn't help here — the throw is server-side from SystemLogQueue::waitFlush. CIDB shows 23 hits in 30 days across PRs #99854 (13), #104217 (7), #104947 (1), #104714 (1), exclusively when query_log backlog is heavy on parallel runners. Cleanest fix is to make that timeout a server setting (default still safe, but bumpable) or just raise the constant to ~600s; I have a follow-up task open to land that as a separate PR.

Session: cron:clickhouse-ci-task-worker:20260520-211500.

@groeneai

Copy link
Copy Markdown
Contributor

Third of the three flaky tests in this bundle is now in flight: #105484 — bumps the hardcoded SystemLogQueue::waitFlush timeout from 180s to 600s to fix 02345_implicit_transaction failing with TIMEOUT_EXCEEDED on parallel CI runners.

Bundle status:

CIDB pattern for 02345: 23 master hits across 4 distinct PRs over the last 30 days, all on parallel runners. The previous 60s -> 180s bump was made for the same reason; raising again is the same shape of fix.

@Algunenano

Copy link
Copy Markdown
Member

#105457 — 01563_distributed_query_finish (CI log-sender bursts) — @Algunenano

@groeneai Please make a note to stop pinging me on unrelated PRs. When talking about flaky checks and its fixes, just mention the PR, no need to mention the author. Otherwise I get multiple pings that are completely unrelated to my work (I had half a dozen related to this exact fix I've made)

@groeneai

Copy link
Copy Markdown
Contributor

@Algunenano Noted, sorry for the noise. Going forward, when referencing a sibling fix PR in a thread the author isn't subscribed to, I'll use the bare PR number (e.g. #105457) instead of cross-tagging. The rule is memorized for future sessions.

@antoniofilipovic

Copy link
Copy Markdown
Contributor Author

@groeneai Make yourself useful (and Nvidia stocks go up) and fix 01563_distributed_query_finish, 02435_rollback_cancelled_queries, 02345_implicit_transaction

@rschu1ze is there anything else I can help with as the failures on PR seem to be unrelated? Basically we have to wait for the fixes to land on master, I can then rebase and when the checks pass we merge?

@rschu1ze

Copy link
Copy Markdown
Member

@antoniofilipovic All good, no need to do anything else from your side. I'll take over.

@clickhouse-gh

clickhouse-gh Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.10% 84.10% +0.00%
Functions 91.40% 91.40% +0.00%
Branches 76.60% 76.50% -0.10%

Changed lines: 98.10% (103/105) | lost baseline coverage: 1 line(s) · Uncovered code

Full report · Diff report

@rschu1ze

Copy link
Copy Markdown
Member

@rschu1ze rschu1ze added this pull request to the merge queue May 22, 2026
Merged via the queue into ClickHouse:master with commit 82517ee May 22, 2026
163 of 166 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label May 22, 2026
DavidHe-2008 pushed a commit to DavidHe-2008/ClickHouse that referenced this pull request Jun 1, 2026
…-add-precision-param-format-readable-funcs

Add precision as parameter for format readable functions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-feature Pull request with new product feature 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.

Add precision as a parameter for formatReadable* functions

8 participants