Repository navigation
Conversation
|
@rienath Can you take a look when you have freetime? |
|
Workflow [PR], commit [0821ab6] Summary: ✅
AI ReviewSummaryThis PR adds Missing context / blind spots
Findings
Final VerdictStatus: Minimum required action: fix the |
|
@rienath seem like the CI look good, can you take a look? |
|
@phulv94 please resolve conflicts |
I've resolved conflicts. |
output_format_float_precision setting to limit decimal digits in float output
rienath
left a comment
There was a problem hiding this comment.
Thanks for working on this! The overall approach looks good. There are a couple of issues to address before merge.
With the current implementation, ToFixed always pads with trailing zeroes up to the requested precision, even when they carry no information. For example:
:) SELECT (1.1::BFloat16) settings output_format_float_precision=0;
-- 1.09375
:) SELECT (1.1::BFloat16) settings output_format_float_precision=30;
-- 1.093750000000000000000000000000The exact representation has only 6 meaningful digits, but we get 24 extra zeroes. Similarly for negative zero:
:) SELECT (-0.0::BFloat16) settings output_format_float_precision=1;
-- -0.0
:) SELECT (-0.0::BFloat16) settings output_format_float_precision=0;
-- -0The setting should mean "round to at most N decimal places", not "always pad to N decimal places". It would be great to strip trailing zeroes (and the trailing decimal point if it becomes unnecessary), so that output_format_float_precision = 30 produces 1.09375, not 1.093750000000000000000000000000.
Another important problem is numbers with magnitude >= 10^60 throw because ToFixed can't represent them. A format setting should never cause previously-working queries to fail on valid data.
:) SELECT 1e61 settings output_format_float_precision=0;
-- 1e61
:) SELECT 1e61 settings output_format_float_precision=1;
-- Code: 28. DB::Exception: Cannot print floating point number. (CANNOT_PRINT_FLOAT_OR_DOUBLE_NUMBER)When you fixe these, please add regression tests. You could use the examples above
…loat-precision-setting
…loat-precision-setting
…ings.h in feature_docs hook Address review feedback on `output_format_float_precision`: - Clarify in the setting description that values whose shortest representation is in scientific notation are emitted as-is (the mantissa may exceed the requested precision) so callers know what to expect for very large or very small magnitudes. Also document the valid range explicitly. - Extend `ci/jobs/scripts/workflow_hooks/feature_docs.py` to recognize `*Settings.h` files containing `DECLARE(` macros as embedded documentation, in the same way `*Settings.cpp` files containing `DECLARE_SETTING` are already accepted. Format settings put their per-setting `DECLARE(...)` blocks (with description strings) in `FormatFactorySettings.h`, so the previous hook treated them as undocumented even when the description was written inline. ClickHouse#99721 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The CI tool's gh token does not have the workflow scope, so the master merge brought in many `.github/workflows/*.yml` updates that the remote rejects on push. Restore those workflow files to their pre-merge state. The workflows on master will apply once this PR is merged. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Workflow files in this branch were stale or had been deleted as a workaround for GitHub's workflow-scope check. Restoring them to match `master` so the PR diff no longer contains those unrelated changes.
…ry.cpp` Master is now 26.6, so new settings introduced under this branch must be registered in the 26.6 block. The 26.5 placement caused Fast test `02995_new_settings_history` to fail with "PLEASE ADD THE SETTING VALUE CHANGE TO SettingsChangesHistory.cpp" because the test filters for versions strictly greater than 26.5. Also clarify the setting description in `FormatFactorySettings.h` to match the actual fallback behavior: scientific notation is used only as a fallback when fixed notation cannot represent the value (large magnitude makes `ToFixed` fail) or when rounding to the requested precision would lose all significant digits (mantissa would become `±0`). The previous wording read as if all scientific-notation defaults were emitted as-is, which is not true for moderate magnitudes where `ToFixed` succeeds.
The master merge updated .github/workflows/{master,pull_request}.yml; restore
them to the fork branch state so the push does not require the workflow OAuth
scope. These generated files do not affect the PR's CI.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
These changes to CI workflow / infrastructure files were unrelated to the purpose of this pull request and were introduced accidentally (stale base branch). Restoring them to match `master`.
|
Let's see what the perf tests show here. The three-argument Might be negligible (ThinLTO can fold it back in), so perf decides. If it shows up, we can keep template <typename T> requires is_floating_point<T>
void writeFloatTextWithPrecision(T x, WriteBuffer & buf, const FormatSettings & settings);
extern template void writeFloatTextWithPrecision(Float64, WriteBuffer &, const FormatSettings &);
extern template void writeFloatTextWithPrecision(Float32, WriteBuffer &, const FormatSettings &);
extern template void writeFloatTextWithPrecision(BFloat16, WriteBuffer &, const FormatSettings &);
template <typename T> requires is_floating_point<T>
inline void writeFloatText(T x, WriteBuffer & buf, const FormatSettings & settings)
{
if (settings.float_precision == 0 || !isFinite(x))
writeFloatText(x, buf);
else
writeFloatTextWithPrecision(x, buf, settings);
} |
…loat-precision-setting
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 75/75 (100.00%) | Lost baseline coverage: none · Uncovered code |
When set to 0 (the default), the existing shortest round-trip representation (dragonbox) is used. When set to N, values are rounded to N decimal places using the double-conversion library's ToFixed. Closes #99199
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Add output_format_float_precision setting to control the number of decimal digits in floating-point text output.
Documentation entry for user-facing changes
Note
Medium Risk
Changes core float serialization for text/JSON outputs and adds a new setting that can affect query results’ textual representations; mistakes could impact client parsing or tests but are bounded to formatting behavior.
Overview
Adds a new
output_format_float_precisionformat setting to cap fractional digits in floating-point text output (with range checking) while keeping the default shortest round-trip representation when set to0.Plumbs the setting through
FormatSettings/FormatFactoryand switches numeric serialization to use a newwriteFloatText(..., settings)path forFloat32/Float64/BFloat16, including JSON number output, with special handling for non-finite values and scientific-notation fallbacks.Updates settings history and CI doc-change detection to recognize
DECLARE(...)blocks in settings headers, and adds a stateless test covering rounding, stripping trailing zeros, edge cases, and error handling.Reviewed by Cursor Bugbot for commit d27d66d. Bugbot is set up for automated code reviews on this repo. Configure here.
Version info
26.6.1.376